-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathexercise7.js
executable file
·37 lines (33 loc) · 987 Bytes
/
exercise7.js
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
$(document).ready(function () {
$("input[type='password']").keyup(function () {
var pw1 = $("#password1").val();
var pw2 = $("#password2").val();
var isError = false;
if (pw1.length > 0) {
if (pw1.length < 6) {
$("#pw1_check").html("Too short");
isError = true;
}
else {
$("#pw1_check").html("");
}
if (pw2.length > 0 && pw1 !== pw2) {
$("#pw2_check").html("The two passwords don't match");
isError = true;
}
else {
$("#pw2_check").html("");
}
}
else {
$("#pw1_check").html("");
}
// show the submit button only if everything is ok
if (pw1.length > 0 && pw2.length > 0 && !isError) {
$("#submitBtn").show();
}
else {
$("#submitBtn").hide();
}
});
});