-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcar.js
More file actions
148 lines (137 loc) · 4.6 KB
/
car.js
File metadata and controls
148 lines (137 loc) · 4.6 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
function test()
{
var h=document.htmlform.davinder.value;
var i=document.htmlform.davinder1.value;
var j=document.htmlform.davinder2.value;
var k=document.htmlform.davinder3.value;
var dValidate=document.htmlform.mydate.value;
var rent = document.htmlform.rent.value;
var numbers = /^[a-zA-Z0-9]+$/;
var vin = document.htmlform.vin.value;
var spec = document.htmlform.spec.value;
var mile = document.htmlform.hello.value;
var snehi = /^[0-9]+$/;
var dummiy = document.htmlform.extra123.value;
if (h=="123")
{
alert("Select Fleet");
document.htmlform.davinder.focus;
return false;
}
if (i=="123")
{
alert("select car make");
document.htmlform.davinder1.focus;
return false;
}
if (j=="123")
{
alert("select car model");
document.htmlform.davinder2.focus;
return false;
}
if (k=="123")
{
alert("select car year");
document.htmlform.davinder3.focus;
return false;
}
if(dValidate!="")
{
var arDValidate=dValidate.split("/");
if(arDValidate.length==3)
{
if(arDValidate[0].length!=2 || (arDValidate[0]>32))
{
alert("Wrong Date format");
document.htmlform.mydate.focus();
return false;
}
else if(arDValidate[1].length!=2 || (arDValidate[1]>13))
{
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");
return false;
}
}
else
{
alert("Date is blank");
document.htmlform.mydate.focus();
return false;
}
if(vin=="")
{
alert("Please insert vin number");
document.htmlform.vin.focus();
return false;
}
if(vin.match(numbers))
{
}
else
{
alert('Please input alphanumeric only');
document.htmlform.vin.focus();
return false;
}
if(spec=="")
{
alert("Please enter specifications");
return false;
}
if(mile=="")
{
alert("Please insert mileage field");
document.htmlform.hello.focus();
return false;
}
if(mile.match(snehi))
{
}
else
{
alert('Please input numbers only in mileage');
document.htmlform.hello.focus();
return false;
}
if(rent=="")
{
alert("Please insert rent field");
document.htmlform.rent.focus();
return false;
}
if(rent>20000) {
alert("Select value of rent less than 20000");
document.htmlform.rent.focus();
return false;
}
if(dummiy=="")
{
alert("Please insert extra value");
document.htmlform.extra123.focus();
return false;
}
}