-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpass.js
62 lines (55 loc) · 1.51 KB
/
pass.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
56
57
58
59
60
61
62
var myInput=document.getElementById("pass");
var letter=document.getElementById("letter");
var capital=document.getElementById("capital");
var number=document.getElementById("number");
var length = document.getElementById("length");
myInput.onfocus=function()
{
document.getElementById("message").style.display="block";
}
myInput.onblur=function()
{
document.getElementById("message").style.display="none";
}
myInput.onkeyup=function()
{
var lowercaseletters=/[a-z]/g;
if(myInput.value.match(lowercaseletters))
{
letter.classList.remove("invalid");
letter.classList.add("valid");
}
else{
letter.classList.remove("valid");
letter.classList.add("invalid");
}
var uppercaseletters=/[A-Z]/g;
if(myInput.value.match(uppercaseletters))
{
capital.classList.remove("invalid");
capital.classList.add("valid");
}
else{
capital.classList.remove("valid");
capital.classList.add("invalid");
}
var numbers=/[0-9]/g;
if(myInput.value.match(numbers))
{
number.classList.remove("invalid");
number.classList.add("valid");
}
else{
number.classList.remove("valid");
number.classList.add("invalid");
}
if(myInput.value.length>=8)
{
length.classList.remove("invalid");
length.classList.add("valid");
}
else{
length.classList.remove("valid");
length.classList.add("invalid");
}
}