-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathM3L2.html
33 lines (28 loc) · 788 Bytes
/
M3L2.html
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
31
32
33
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<h2>javascript validate input</h2>
<p>please input a number between 1 and 10:</p>
<input id="numb">
<button type="button" onclick="myFunction()">Submit</button>
<p id="demo"></p>
<script>
function myFunction(){
var x, text;
document.getElementById("numb").value;
if(isNaN(x) || x < 1 || x > 10){
text = "input not valid";
}else{
text = "input oke";
}
document.getElementById("demo").innerHTML = text;
}
</script>
</body>
</html>