-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathError.html
More file actions
30 lines (28 loc) · 778 Bytes
/
Error.html
File metadata and controls
30 lines (28 loc) · 778 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<!DOCTYPE html>
<html>
<body>
<p>Please input a number between 5 and 10:</p>
<input id="demo" type="text" />
<button type="button" onclick="myFunction()">Test Input</button>
<p id="p01"></p>
<script>
function myFunction() {
const message = document.getElementById("p01");
message.innerHTML = "";
let x = document.getElementById("demo").value;
try
{
if (x == "") throw "empty";
if (isNaN(x)) throw "not a number";
x = Number(x);
if (x < 5) throw "too low";
if (x > 10) throw "too high";
}
catch (err)
{
message.innerHTML = "Input is " + err;
}
}
</script>
</body>
</html>