-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
159 lines (138 loc) · 4.89 KB
/
index.html
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
<!DOCTYPE html>
<html>
<head>
<title>input field validation</title>
<link rel="stylesheet" href="css/main.css"/>
</head>
<body>
<p>
<H3>Form Validation Successful.</H3>
</p>
<div class="container">
<form id="myform" action="pages/multiple_form_validation.html">
<div class="form_horizontal">
<div class="form_element">
<label>Username : </label>
<input id="username" value="Abhijit">
</div>
<div class="form_element">
<label>Email : </label>
<input id="email">
</div>
</div>
<div class="form_horizontal">
<div class="form_element">
<label>Password : </label>
<input id="password" type="password">
</div>
<div class="form_element">
<label>Re-Password : </label>
<input id="repassword" type="password">
</div>
</div>
<div class="form_horizontal">
<div class="form_element">
<label>Name : </label>
<input id="name">
</div>
<div class="form_element">
<label>Mobile : </label>
<input id="mobile" type="number">
</div>
</div>
<div class="form_horizontal">
<div class="form_element">
<label>Gender :</label>
<input id="radio" type="radio" name="rad1">Male<br/>
<input type="radio" name="rad1">Female
</div>
<div class="form_element">
<label>Birth Year Range : </label>
<select id="dropdown">
<option value="null">Select Your Range</option>
<option value="1">(1986-1990)</option>
<option value="2">(1991-1995)</option>
<option value="3">(1996-2000)</option>
<option value="4">(after 2000)</option>
</select>
</div>
<div class="form_horizontal">
<div class="form_element">
<label>File : </label>
<input id="file" type="file" style="width:89px;">
</div>
<div class="form_element">
<label>PIN Code : </label>
<input id="pincode" type="number">
</div>
</div>
<div class="form_horizontal">
<div class="form_element">
<label>Starting Date : </label>
<input id="to_date" type="date">
</div>
<div class="form_element">
<label>Ending date : </label>
<input id="from_date" type="date">
</div>
</div>
<div class="form_horizontal">
<div class="form_element">
<label>Self Defined : </label>
<input id="newField">
</div>
<div class="form_element">
<label>Range (10-20) : </label>
<input id="range">
</div>
</div>
</div>
<div class="form_horizontal">
<input class="submit" type="submit">
</div>
</form>
</div>
<script src="js/validation.js"></script>
<script>
Validation.fields['myform'] = [
{
id: "username",
verify: {
name: "uname",
url: "api/verify.php",
errormsg: "This username already exists!!!",
method: "POST"
}
},
{id: "email", type: "email"},
{id: "password", maxlength: 10, minlength: 4, required: true, match: "repassword"},
{id: "repassword", required: true},
{id: "name", type: "name"},
{id: "mobile", type: "mobile"},
{id: "radio", type: "radio"},
{id: "dropdown", type: "dropdown"},
{id: "file", required: true},
{id: "pincode", fixedlength: 5},
{id: "to_date", datefrom: "from_date", required: true},
{id: "from_date", required: true},
{id: "newField", custom: "testfunc"},
{id: "range", minvalue: 10, maxvalue: 20}
];
Validation.Initiate();
function testfunc() {
/*
Predefind elements:
------------------
Validation.element.id --- to get the id of the current field
Validation.element.value --- to get the value of the current field
Validation.message.add(" To add your custom message. ") --- Add your message block to that field.
*/
if (Validation.element.value != "123") {
Validation.message.add("Custom message block :Your id :" + Validation.element.id + " and Value should be '123'");
return false;
}
return true;
}
</script>
</body>
</html>