-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdriver.js
More file actions
172 lines (152 loc) · 5.9 KB
/
driver.js
File metadata and controls
172 lines (152 loc) · 5.9 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
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
function allnumeric()
{
var name = document.htmlform.fname.value;
var lname = document.htmlform.lastname.value;
var d = document.htmlform.mydate;
var address = document.htmlform.address;
var city = document.htmlform.city;
var email = document.htmlform.email;
var numbers = /^[A-z]+$/;
var dValidate=document.htmlform.mydate.value;
var x=document.forms["htmlform"]["email"].value;
var atpos=x.indexOf("@");
var dotpos=x.lastIndexOf(".");
var abcd=document.htmlform.abcd.value;
if (name=="" || name.length>20)
{
alert("Please enter first name with maximum 20 alphabets");
document.htmlform.fname.focus();
return false;
}
if(name.match(numbers))
{
//do nothing
}
else
{
alert ("Please enter only alphabets");
document.htmlform.fname.focus();
return false;
}
if (lname=="" || lname.length>20)
{
alert ("Please enter lastname with maximum 20 character");
document.htmlform.lastname.focus();
return false;
}
if(lname.match(numbers))
{
//do nothing
}
else
{
alert('Please input characters only');
document.htmlform.lastname.focus();
return false;
}
if (d.value=="")
{
alert("Please fill the date field");
document.htmlform.mydate.focus();
return false;
}
if(dValidate!="")
{
var arDValidate=dValidate.split("/");
if(arDValidate.length==3)
{
if(arDValidate[0].length!=2 || (arDValidate[0]>12))
{
alert("Wrong Date format");
document.htmlform.mydate.focus();
return false;
}
else if(arDValidate[1].length!=2 || (arDValidate[1]>31))
{
alert("Wrong Month format");
document.htmlform.mydate.focus();
return false;
}
else if(arDValidate[2].length!=4 || (arDValidate[2]<1900))
{
alert("Wrong Year format");
document.htmlform.mydate.focus();
return false;
}
else
{
var dateDate=new Date(arDValidate[2],arDValidate[1]-1,arDValidate[0]);
if((arDValidate[0]!=dateDate.getDate()))
{
alert("Wrong Date Enter e.g date month year is not correct 31 feb 2009");
document.htmlform.mydate.focus();
return false;
}
}
}
else
{
alert("Wrong Format");
document.htmlform.mydate.focus();
return false;
}
}
else
{
alert("Date is blank");
document.htmlform.mydate.focus();
return false;
}
if (address.value=="" || address.value.length<20)
{
alert("Please enter Address field, it should be maximum than 20 characters");
document.htmlform.address.focus();
return false;
}
if (city.value=="")
{
alert("Please enter City field");
document.htmlform.city.focus();
return false;
}
if(city.value.match(numbers))
{
//do nothing
}
else
{
alert('Please input only alphabets without spaces in city field');
document.htmlform.city.focus();
return false;
}
if (email.value=="")
{
alert("Please Enter Email ");
document.htmlform.email.focus();
return false;
}
if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length)
{
alert("Not a valid e-mail address");
document.htmlform.email.focus();
return false;
}
if(abcd=="")
{
alert("please Enter the Contact Number");
document.htmlform.abcd.focus();
return false;
}
if(isNaN(abcd))
{
alert("Enter the valid Mobile Number(Like : 9566137117)");
document.htmlform.abcd.focus();
return false;
}
if(abcd.length !=10)
{
alert("enter only 10 character");
document.htmlform.abcd.focus();
return false;
}
}