-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
77 lines (72 loc) · 2.14 KB
/
app.js
File metadata and controls
77 lines (72 loc) · 2.14 KB
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
70
71
72
73
74
75
76
77
function Strength(password) {
let i = 0;
if (password.length > 6) {
i++;
}
if (password.length >= 6) {
i++;
}
if (/[A-Z]/.test(password)) {
i++;
}
if (/[0-9]/.test(password)) {
i++
}
if (/[A-Za-z0-8]/.test(password)) {
i++
}
// if (/[A-Za-z0-8#?!@$%^&*-^$|\s+]/.test(password)) {
// i++
// }
return i;
}
let container = document.querySelector('.container');
document.addEventListener("keyup", function (e) {
let password = document.querySelector('#myPassword').value;
let strength = Strength(password);
if (strength <= 0) {
container.classList.remove('weak');
container.classList.remove('medium');
container.classList.remove('strong');
container.classList.remove('VeryStrong');
}
else if (strength <= 2) {
container.classList.add('weak');
container.classList.remove('medium');
container.classList.remove('strong');
container.classList.remove('VeryStrong');
}
else if (strength >= 2 && strength <= 4) {
container.classList.remove('weak');
container.classList.add('medium');
container.classList.remove('strong');
container.classList.remove('VeryStrong');
}
else if (strength >= 4 && strength <= 8) {
container.classList.remove('weak');
container.classList.remove('medium');
container.classList.add('strong');
container.classList.remove('VeryStrong');
}
else {
container.classList.remove('weak');
container.classList.remove('medium');
container.classList.remove('strong');
container.classList.add('VeryStrong')
}
})
/*-------Password Show & Hide Function-------*/
let pws = document.querySelector('#myPassword');
let show = document.querySelector('.show');
show.onclick = function () {
if (pws.value !== "") {
if (pws.type === 'password') {
pws.setAttribute('type', 'text');
show.classList.add('hide');
}
else {
pws.setAttribute('type', 'password');
show.classList.remove('hide');
}
}
}