-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvalidate-olds.js
101 lines (83 loc) · 3.63 KB
/
validate-olds.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
function val() {
var name = document.getElementById('name').value;
var email = document.getElementById('email').value;
var mobile = document.getElementById('mobile').value;
var subject = document.getElementById('subject').value;
var message = document.getElementById('message').value;
var alphaExp = /^[a-z A-Z]+$/;
//Name
if (name != "") {
if (!name.match(alphaExp)) {
alert("Please Enter Letters Only !");
document.getElementById('name').focus();
return false;
}
}
if (name == "") {
alert("Please Enter Name");
document.getElementById('name').focus();
return false;
}
//user_email
if (email == "") {
alert("Please Enter Your E-mail");
document.getElementById('email').focus();
return false;
}
if (email != "") {
if (document.getElementById('email').value.length > 0) {
i = document.getElementById('email').value.indexOf("@");
j = document.getElementById('email').value.indexOf(".", i);
k = document.getElementById('email').value.indexOf(",");
kk = document.getElementById('email').value.indexOf(" ");
jj = document.getElementById('email').value.lastIndexOf(".");
len = document.getElementById('email').value.length;
if ((i > 0) && (j > (1 + 1)) && (k == -1) && (kk == -1) && (len - jj >= 2))
//&&(len-jj<=3))
{
//document.cform.ConfirmEmail.focus();//
} else {
alert("Please enter an exact email address.\n" + document.getElementById('email').value +
" is invalid.");
document.getElementById('email').focus();
return false;
}
}
}
//mobile
if (mobile == "") {
alert("Please Enter Your Mobile Number");
document.getElementById('mobile').focus();
return false;
}
if (mobile != "") {
if (!isNaN(mobile)) {
if (mobile.charAt(0) != "9" && mobile.charAt(0) != "8" && mobile.charAt(0) != "7") {
alert("Please start mobile number with 7 to 9 !");
document.getElementById('mobile').focus();
return false;
}
if (mobile.length < 10 || mobile.length > 10) {
alert("Please enter valid mobile number ! ");
document.getElementById('mobile').focus();
return false;
}
} else {
alert("Please enter valid mobile number !");
document.getElementById('mobile').focus();
return false;
}
}
//subject
if (subject == "") {
alert("Please Enter subject");
document.getElementById('subject').focus();
return false;
}
//Message
if (message == "") {
alert("Please Enter Message");
document.getElementById('message').focus();
return false;
}
}