-
Notifications
You must be signed in to change notification settings - Fork 110
/
Register.js
34 lines (29 loc) · 1.25 KB
/
Register.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
const passwordInput = document.querySelector("#password_data");
passwordInput.addEventListener("keyup", () => {
let password = passwordInput.value;
var strongRegex = new RegExp("^(?=.{14,})(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*\\W).*$", "g");
var mediumRegex = new RegExp("^(?=.{10,})(((?=.*[A-Z])(?=.*[a-z]))|((?=.*[A-Z])(?=.*[0-9]))|((?=.*[a-z])(?=.*[0-9]))).*$", "g");
if(password.length===0)
{
document.querySelector(".safety").innerHTML = "Enter Password";
}
else
{
document.querySelector(".safety").innerHTML = '<span>Password Strength</span><span class="line" id="line1"></span><span class="line" id="line2"></span><span class="line" id="line3"></span>';
}
if (strongRegex.test(password))
{
document.querySelector("#line1").style.background = "green";
document.querySelector("#line2").style.background = "green";
document.querySelector("#line3").style.background = "green";
}
else if (mediumRegex.test(password))
{
document.querySelector("#line1").style.background = "yellow";
document.querySelector("#line2").style.background = "yellow";
}
else
{
document.querySelector("#line1").style.background = "red";
}
})