-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
1,177 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
body { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
} | ||
.numberForm, | ||
form { | ||
display: flex; | ||
flex-direction: column; | ||
margin: 10px; | ||
} | ||
form { | ||
justify-content: center; | ||
align-items: center; | ||
} | ||
input, | ||
button { | ||
padding: 10px; | ||
margin: 5px; | ||
} | ||
#result { | ||
margin-top: 20px; | ||
text-align: center; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<meta charset="utf-8" /> | ||
<link rel="stylesheet" href="/style.css" /> | ||
</head> | ||
<body> | ||
<div class="numberForm"> | ||
<form id="numberForm"> | ||
<label method="post">Enter a positive integer</label> | ||
<input type="text" /> | ||
<button type="submit">Submit</button> | ||
</form> | ||
<h1 id="result"><h1></h1> | ||
</div> | ||
|
||
</body> | ||
|
||
<script> | ||
const numberForm = document.getElementById("numberForm"); | ||
|
||
const result=document.getElementById("result") | ||
|
||
numberForm.addEventListener("submit",(event)=>{ | ||
const numberValue = document.querySelector("input").value; | ||
event.preventDefault() | ||
if(numberValue === ''){ | ||
result.textContent='Lack of Parameter' | ||
}else if(!Number.isInteger(Number(numberValue))|| numberValue<=0||isNaN(numberValue)){ | ||
result.textContent='Wrong Parameter' | ||
}else{ | ||
fetch(`/getData?number=${numberValue}`) | ||
.then(function(response){return response.text()}) | ||
.then(function(data){result.textContent = `${data}`}) | ||
|
||
} | ||
} | ||
); | ||
|
||
|
||
</script> | ||
</html> |
Oops, something went wrong.