-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathentry.js
More file actions
47 lines (37 loc) · 1.48 KB
/
entry.js
File metadata and controls
47 lines (37 loc) · 1.48 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
let entryForm = document.forms.def
let usersInput = document.querySelectorAll("input")
entryForm.onsubmit=(e)=>{
e.preventDefault()
let formErr= {
usernameErr: '',
passwordErr: '',
aspiringErr: '',
contactErr: '',
}
let username = entryForm.username.value.trim();
let password = entryForm.password.value.trim();
let aspiring = entryForm.aspiring.value.trim();
let contact = entryForm.contact.value.trim();
if(username == ''){
formErr.usernameErr= 'please fill in the blank';
}else if(username.length < 8 || username.includes("[A-Z]")){
formErr.usernameErr= 'must start with a uppercase[A-Z] with more than 8 characters';
}else if(password == ''){
formErr.passwordErr='please fill in the blank';
}else if(password.length < 8 || password.includes("@$#%*!")){
formErr.passwordErr='must be more than 8 characters with any of the special characters["@$#%*!]';
}else if(aspiring == ''){
formErr.aspiringErr='invalid password';
}else if(contact == ''){
formErr.contactErr = 'this field is requried';
}else{
alert("Congratulation you've successfully submitted your application,Thanks for time your ");
}
let errElement = document.querySelectorAll('.err')
console.log(errElement)
for(let i=0; i < errElement.length; i++){
let errElements = errElement[i];
console.log(formErr);
errElements.innerHTML = formErr[""+errElements.dataset.err+""]
}
}