-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscriptSignup.js
More file actions
76 lines (62 loc) · 2.7 KB
/
scriptSignup.js
File metadata and controls
76 lines (62 loc) · 2.7 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
66
67
68
69
70
71
72
73
74
75
76
const inputElement=document.getElementsByClassName('inputclass');
const inputbox=document.getElementsByClassName('inputwicon');
// For email box
inputElement[0].addEventListener('focus', (event) => {
inputbox[0].style.borderBottom="2px solid #43cdf0";
})
inputElement[0].addEventListener('blur', (event) => {
inputbox[0].style.borderBottom="2px solid #0a0403";
})
// For username box
inputElement[1].addEventListener('focus', (event) => {
inputbox[1].style.borderBottom="2px solid #43cdf0";
})
inputElement[1].addEventListener('blur', (event) => {
inputbox[1].style.borderBottom="2px solid #0a0403";
})
//for password box
inputElement[2].addEventListener('focus', (event) => {
inputbox[2].style.borderBottom="2px solid #43cdf0";
})
inputElement[2].addEventListener('blur', (event) => {
inputbox[2].style.borderBottom="2px solid #0a0403";
} )
//validation
const loginbutton=document.getElementsByClassName('signupbutton')[0];
loginbutton.addEventListener('click', (event) => {
const email=inputElement[0].value;
const username=inputElement[1].value;
const password=inputElement[2].value;
if((email=='' || email.length<11) & inputbox[0].lastChild.className!="fa-solid fa-circle-exclamation"){
//alert('Please fill all the fields');
const newele = document.createElement("i");
newele.className="fa-solid fa-circle-exclamation";
newele.style.color = 'red';
newele.style.marginRight='10px';
inputbox[0].appendChild(newele);
}
if((username=='' || username.length<8) & inputbox[1].lastChild.className!="fa-solid fa-circle-exclamation"){
//alert('Please fill all the fields');
const newele = document.createElement("i");
newele.className="fa-solid fa-circle-exclamation";
newele.style.color = 'red';
newele.style.marginRight='10px';
inputbox[1].appendChild(newele);
}
if((password=='' || password.length<8) & inputbox[2].lastChild.className!="fa-solid fa-circle-exclamation"){
//alert('Please fill all the fields');
const newele = document.createElement("i");
newele.className="fa-solid fa-circle-exclamation";
newele.style.color='red';
newele.style.marginRight='10px';
inputbox[2].appendChild(newele);
}
})
loginbutton.addEventListener('blur', (event) => {
if(inputbox[0].lastChild.className=="fa-solid fa-circle-exclamation"){
inputbox[0].removeChild(inputbox[0].lastChild);}
if(inputbox[1].lastChild.className=="fa-solid fa-circle-exclamation"){
inputbox[1].removeChild(inputbox[1].lastChild);}
if(inputbox[2].lastChild.className=="fa-solid fa-circle-exclamation"){
inputbox[2].removeChild(inputbox[2].lastChild);}
})