-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathvalidate2.js
More file actions
60 lines (51 loc) · 1.43 KB
/
Copy pathvalidate2.js
File metadata and controls
60 lines (51 loc) · 1.43 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
function ValidateForm() {
var email=document.getElementById("email");
var username=document.getElementById("username");
var letter=/^[a-z0-9]+$/;
var f=0;
if (email.value.length==0){
email.className="wrong-input";
email.nextElementSibling.innerHTML=" Email can't be blank";
}else if(email.value.indexOf('@',0)<=0){
email.className="wrong-input";
email.nextElementSibling.innerHTML=" Invalid @ position";
}else if(email.value.indexOf('.',0)<0){
email.className="wrong-input";
email.nextElementSibling.innerHTML=" Invalid . position";
}else if(emailvalid()==false){
email.className="wrong-input";
email.nextElementSibling.innerHTML=" Enter valid E-mail id";
}
else if(f==1){
name.className="form-control";
name.nextElementSibling.innerHTML="";
}else{
email.className="form-control";
email.nextElementSibling.innerHTML="";
f=f+1;
}
if (password.value.length==0){
password.className="wrong-input";
password.nextElementSibling.innerHTML="Password can't be blank";
}
else if(f==2){
password.className="form-control";
password.nextElementSibling.innerHTML="";
}else{
password.className="form-control";
password.nextElementSibling.innerHTML="";
f=f+1;
}
if (f==2){
valid=true;
}else{valid=false;}
return valid;
}
function emailvalid(){
var emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i
var b=emailfilter.test(email.value);
if(b==false)
{
return false;
}
}