-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
71 lines (66 loc) · 2.81 KB
/
app.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
63
64
65
66
67
68
69
70
71
function checkPassword() {
let user = document.querySelector("#user").value
let error = document.querySelector("#error")
let CapitalLetter = false
let SmallLetter = false
let hasNumber = false;
let hasSpecialChar = false;
let specialChars = ['!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '-', '_', '=', '+', '[', ']', '{', '}', ';', ':', '"', "'", '<', '>', ',', '.', '?', '/'];
if (user.trim() === "") {
console.log("input Empity");
error.innerHTML = ("input Empity");
error.className = "error";
} else {
if (user.length > 8) {
for (let i = 0; i < user.length; i++) {
if (user[i] >= "A" && user[i] <= "Z") {
CapitalLetter = true
};
if (user[i] >= "a" && user[i] <= "z") {
SmallLetter = true
};
if (user[i] >= "0" && user[i] <= "9") {
hasNumber = true;
}
if (specialChars.includes(user[i])) {
hasSpecialChar = true; }
}
if (CapitalLetter !== true) {
console.log("Enter a password with at least one capital letter");
error.innerHTML =("Enter a password with at least one capital letter");
error.className = "error";
}
if (SmallLetter !== true ) {
console.log("Enter a password with at least one small letter");
error.innerHTML = ("Enter a password with at least one small letter");
error.className = "error";
}
if (hasNumber !== true) {
console.log("Enter a password with at least one number.");
error.innerHTML = ("Enter a password with at least one number.");
error.className = "error";
}
if (hasSpecialChar !== true) {
console.log("Enter a password with at least one special charector.");
error.innerHTML = ("Enter a password with at least one special charector.");
error.className = "error";
}
if (CapitalLetter && SmallLetter && hasNumber && hasSpecialChar) {
console.log("Correct Password");
error.innerHTML = ("Correct Password");
error.className = "succes";
}
}
else {
console.log("please atleast 8 charector valid");
error.innerHTML = ("please atleast 8 charector valid");
error.className = "error";
}
}
}
const Password = document.querySelector("#user");
const Checkbox = document.querySelector("#show");
Checkbox.addEventListener('click',function(){
const type =Password.getAttribute("type")=== "password" ? "text" : "password";
Password.setAttribute("type",type);
});