-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathform.js
81 lines (60 loc) · 2.51 KB
/
form.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
function validation(){
var username = document.getElementById('username').value;
var pass = document.getElementById('pass').value;
var confirmpass = document.getElementById('conpass').value;
var mobileNumber = document.getElementById('mobileNumber').value;
var emails = document.getElementById('emails').value;
if(username == ""){
document.getElementById('username').innerHTML =" ** Please fill the username field";
alert ( "Please fill in the 'Your Name' box." );
return false;
}
if((username.length <= 2) || (username.length > 20)) {
document.getElementById('username').innerHTML =" ** Username lenght must be between 2 and 20";
return false;
}
if(!isNaN(username)){
document.getElementById('username').innerHTML =" ** only characters are allowed";
return false;
}
if(pass == ""){
document.getElementById('passwords').innerHTML =" ** Please fill the password field";
return false;
}
if((pass.length <= 5) || (pass.length > 20)) {
document.getElementById('passwords').innerHTML =" ** Passwords lenght must be between 5 and 20";
return false;
}
if(pass!=confirmpass){
document.getElementById('confrmpass').innerHTML =" ** Password does not match the confirm password";
return false;
}
if(confirmpass == ""){
document.getElementById('confrmpass').innerHTML =" ** Please fill the confirmpassword field";
return false;
}
if(mobileNumber == ""){
document.getElementById('mobileno').innerHTML =" ** Please fill the mobile NUmber field";
return false;
}
if(isNaN(mobileNumber)){
document.getElementById('mobileno').innerHTML =" ** user must write digits only not characters";
return false;
}
if(mobileNumber.length!=10){
document.getElementById('mobileno').innerHTML =" ** Mobile Number must be 10 digits only";
return false;
}
if(emails == ""){
document.getElementById('emailids').innerHTML =" ** Please fill the email idx` field";
return false;
}
if(emails.indexOf('@') <= 0 ){
document.getElementById('emailids').innerHTML =" ** @ Invalid Position";
return false;
}
if((emails.charAt(emails.length-4)!='.') && (emails.charAt(emails.length-3)!='.')){
document.getElementById('emailids').innerHTML =" ** . Invalid Position";
return false;
}
}