-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
65 lines (64 loc) · 1.67 KB
/
script.js
File metadata and controls
65 lines (64 loc) · 1.67 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
function main(){
var len=0;
var schar=0;
var num=0;
var alph=0;
var paswrd=document.getElementById('textinput').value;
var pbar=document.getElementById('progressBar');
var warn=document.getElementById('warning');
for(var i in paswrd){
if (paswrd[i].charCodeAt(0)>=97 && paswrd[i].charCodeAt(0)<=122 || paswrd[i].charCodeAt(0)>=65 && paswrd[i].charCodeAt(0)<=90){
alph=1;
}
else if (paswrd[i].charCodeAt(0)>=48 && paswrd[i].charCodeAt(0)<=57) {
num=1;
}
else{
schar=1;
}
}
if(paswrd.length>=8){
len=1;
}
else{
len=0;
}
var sum=len+schar+num+alph;
if(sum==1){
pbar.style.backgroundColor="#ff3e36";
pbar.style.width="66px";
warn.innerHTML="Your password is very weak";
}
else if (sum==2) {
pbar.style.backgroundColor="#ff691f";
pbar.style.width="132px";
warn.innerHTML="Your password is weak";
}
else if (sum==3) {
pbar.style.backgroundColor="#ffda36";
pbar.style.width="189px";
warn.innerHTML="Your password is good";
}
else if (sum==4) {
pbar.style.backgroundColor="#0be881";
pbar.style.width="265px";
warn.innerHTML="Your password is strong";
}
else{
pbar.style.backgroundColor="#cccccc";
pbar.style.width="0px";
warn.innerHTML="";
}
}
function show(){
var showbtn=document.getElementById('showbtn');
var textinput=document.getElementById('textinput');
if(textinput.getAttribute("type")=="password"){
textinput.setAttribute("type","text");
showbtn.style.color="#0be881";
}
else{
textinput.setAttribute("type","password");
showbtn.style.color="#808080";
}
}