-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathform.js
More file actions
38 lines (30 loc) · 1.02 KB
/
form.js
File metadata and controls
38 lines (30 loc) · 1.02 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
let email=document.getElementById('email');
let pwd=document.getElementById('password');
// let error=document.getElementById('error');
let span=document.getElementsByTagName('span');
function validate(){
const regx =/^([A-Za-z0-9\.-]+)@([A-Za-z0-9\-]+).([a-z]{2,3})(.[a-z]{2,3})?$/;
if (regx.test(email.value)){
span[0].innerText = "Your email is valid";
span[0].style.color = "lime";
return passit();
}
else{
span[0].innerText = "Your email is invalid";
span[0].style.color = "red";
return false;
}
}
function passit(){
const pwdpattern = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{6,}$/;
if(pwdpattern.test(pwd.value)){
span[1].innerText = "Your password is valid";
span[1].style.color = "lime";
return true;
}
else{
span[1].innerText = "Your password is invalid";
span[1].style.color = "red";
return false;
}
}