-
Notifications
You must be signed in to change notification settings - Fork 1
/
home.html
37 lines (31 loc) · 869 Bytes
/
home.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
34
35
36
37
<!DOCTYPE html>
<html>
<head>
<title>Number Validation</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
</head>
<body>
Integer 1:
<input type="number" id="int1" />
<br/> Integer 2:
<input type="number" id="int2" />
<br/>
<input type="button" name="add" value="Add" onclick="add()">
<input type="button" name="divide" value="Divide" onclick="divide()">
</body>
<script type="text/javascript">
onerror = unhandled;
function unhandled(msg, url, line) {
alert('There has been an unhandled exception.');
}
function add() {
alert($("#int1").val() + $("#int2").val());
}
function divide() {
if (isNaN($("#int1").val() || isNaN("#int2").val())) {
throw ('One or more values are non-numeric');
}
alert($("#int1").val() / $("#int2").val());
}
</script>
</html>