-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
58 lines (54 loc) · 2 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
const container = document.querySelector(".container"),
pwShowHide = document.querySelectorAll(".showHidePw"),
pwFields = document.querySelectorAll(".password"),
signUp = document.querySelector(".signup-link"),
login = document.querySelector(".login-link"),
name1=document.getElementById('name'),
password=doc.getElementById('password'),
form=document.getElementById('form'),
errorElement=document.getElementById('error')
;
// js code to show/hide password and change icon
pwShowHide.forEach(eyeIcon =>{
eyeIcon.addEventListener("click", ()=>{
pwFields.forEach(pwField =>{
if(pwField.type ==="password"){
pwField.type = "text";
pwShowHide.forEach(icon =>{
icon.classList.replace("uil-eye-slash", "uil-eye");
})
}else{
pwField.type = "password";
pwShowHide.forEach(icon =>{
icon.classList.replace("uil-eye", "uil-eye-slash");
})
}
})
})
})
// js code to appear signup and login form
signUp.addEventListener("click", ( )=>{
container.classList.add("active");
});
login.addEventListener("click", ( )=>{
container.classList.remove("active");
});
form.addEventListener('submit',(e)=>{
let message=[]
if(name1.value===''||name1.value==null){
message.push('Name is required')
}
if(password.value.length<=6){
message.push('Password must be longer than 6 characters')
}
if(password.value.length>=20){
message.push('Password must be less than 20 characters')
}
if(password.value==='password'){
message.push('Password cannot be password')
}
if(message.length>0){
e.preventDefault()
errorElement.innerText=message.join(', ')
}
})