-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
55 lines (47 loc) · 1.51 KB
/
script.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
let pw = document.getElementById('password');
let cpw = document.querySelector('#confpassword');
let rpwInfo = document.querySelector('#pw-match');
let upper = document.getElementById("pw-upper");
let number = document.getElementById("pw-numb");
let lower = document.getElementById("pw-lower");
let char = document.getElementById("pw-chars");
let list = document.querySelector(".pw-req");
cpw.addEventListener("input", () => {
if(pw.value !== cpw.value) {
rpwInfo.classList.replace('invisible', 'visible');
} else {
rpwInfo.classList.replace('visible', 'invisible');
}
});
pw.addEventListener("input", () => {
cpw.value = "";
})
pw.addEventListener("input", () => {
// check for number
if(pw.value.match(/(?=.*\d)/) !== null) {
number.style.color = "green";
} else if((pw.value.match(/(?=.*\d)/) === null)) {
number.style.color = "red";
}
// check for lowercase
if(pw.value.match(/(?=.*[a-z])/) !== null) {
lower.style.color = "green";
} else if((pw.value.match(/(?=.*\d)/) === null)) {
lower.style.color = "red";
}
// check for uppercase
if(pw.value.match(/(?=.*[A-Z])/) !== null) {
upper.style.color = "green";
} else if((pw.value.match(/(?=.*\d)/) === null)) {
upper.style.color = "red";
}
// check for 8 chars
if(pw.value.length >= 8) {
char.style.color = "green";
} else if(pw.value.length < 8) {
char.style.color = "red";
}
})
function reload() {
location.reload();
}