forked from 4iz268/cviceni
-
Notifications
You must be signed in to change notification settings - Fork 0
/
10-js-form-password.html
69 lines (38 loc) · 979 Bytes
/
10-js-form-password.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
67
68
69
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>JS password fields</title>
</head>
<body>
<h1>JS password field</h1>
<form id="myForm" onsubmit="return checkForm()">
<label for='first'>First Name</label><br/>
<input type="text" id="first">
<br/><br/>
<label for='last'>Last Name</label><br/>
<input type="text" id="last">
<br/><br/>
<label for='password1'>Password</label><br/>
<input type="password" id="password1">
<br/><br/>
<label for='password2'>Password Confirmation</label><br/>
<input type="password" id="password2">
<br/><br/>
<input type="submit">
</form>
<script>
function checkForm() {
var p1 = document.getElementById('password1').value;
var p2 = document.getElementById('password2').value;
if (p1 == p2 && p1!='' && p2!='') {
return true;
}
else {
alert('Please confirm the password!');
return false;
}
}
</script>
</body>
</html>