-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadditioon.html
66 lines (55 loc) · 1.53 KB
/
additioon.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script>
function add() {
var num1 = document.querySelector("#fnum").value;
if (num1 == "") {
alert("Number First is Required");
return;
}
num1 = parseFloat(num1);
if (isNaN(num1)) {
alert("please provide a valid number");
return;
}
var num2 = document.querySelector("#snum").value;
if (num2 == "") {
alert("Second Number is Required");
return;
}
num2 = parseFloat(num2);
if (isNaN(num2)) {
alert("please provide the valid number");
return;
}
var res = num1 + num2;
document.querySelector("#result").value = res;
}
</script>
</head>
<body>
<div class="wrapper">
<table>
<tr>
<td>First Number</td>
<td><input type="text" id="fnum"></td>
</tr>
<tr>
<td>Second Number</td>
<td><input type="text" id="snum"></td>
</tr>
<tr>
<td>Result</td>
<td><input type="text" id="result"></td>
</tr>
<tr>
<td></td>
<td><input type="button" value="add" onclick="add()"></td>
</tr>
</table>
</div>
</body>
</html>