-
Notifications
You must be signed in to change notification settings - Fork 14
/
index.html
303 lines (288 loc) · 13.2 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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Form Validation for Bootstrap using Ajax, jQuery and PHP</title>
<link rel="stylesheet" type="text/css" href="bootstrap/bootstrap.min.css"></link>
<link rel="stylesheet" type="text/css" href="chosen-optional/chosen.bootstrap.min.css" />
</head>
<body>
<div class='container'>
<div class="row">
<div class='col-lg-12'>
<h2 class='page-header'>
Validate <small>Simple & robust form validation for Bootstrap 3.0, jQuery, Ajax & PHP</small>
</h2>
<ul>
<li>MIT Licence</li>
<li>Copyright 2013 Michael Bignold</li>
<li><a href='https://github.com/cthiggo/validate'>https://github.com/cthiggo/validate</a></li>
</ul>
</div>
</div>
<div class="row">
<div class='col-lg-12'>
<h3 class='page-header'>
Specifications
</h3>
</div>
</div>
<div class="row">
<div class='col-lg-6'>
<h5>Features</h5>
<ul>
<li>Uses Ajax to validate input.</li>
<li>Can be easily modified to check a database for on the fly app-specific validation.</li>
<li>Basic setup using only <code>[data-]</code> properties in HTML tags.</li>
<li>Uses Bootstrap Tooltips for a streamlined & functional user interface.</li>
<li>Only one single <code>.js</code> file to add to your page, and <code>.php</code> file to add to your server.</li>
<li>Works with <a href='https://github.com/alxlit/bootstrap-chosen'>bootstrap-chosen</a> improved select boxes.</li>
</ul>
</div>
<div class='col-lg-6'>
<h5>Dependencies</h5>
<ul>
<li>Requires jQuery 2.0.2+</li>
<li>Requires Bootstrap Tooltips (Bootstrap 2 or 3)</li>
</ul>
</div>
</div>
<div class="row">
<div class='col-lg-12'>
<h3 class='page-header'>Examples</h3>
</div>
</div>
<div class="row">
<div class='col-lg-12'>
<div class='panel'>
<div class='panel-heading'><h4 class='panel-title'>Values required <code>[data-vreq=*]</code></h4></div>
<form id='form1'>
<div class='row'>
<div class='col-lg-4'>
<input id='firstname'
class='form-control input-md'
placeholder='First Name'
data-vreq='1'/>
</div>
<div class='col-lg-8'>
<h5>Type anything in this field. </h5><code>[data-vreq=1]</code>
</div>
</div>
<BR>
<div class='row'>
<div class='col-lg-4'>
<input id='lastname'
class='form-control input-md'
placeholder='Last Name'
data-vreq='0'/>
</div>
<div class='col-lg-8'>
<h5>No value required here. </h5><code>[data-vreq=0]</code>
</div>
</div>
<BR>
<div class='row'>
<div class='col-lg-4'>
<a
class='btn btn-md btn-primary'
data-vsubmit='1'
data-vfunc='doSomething'
data-vclear='1'>Submit</a>
</div>
<div class='col-lg-8'>
<h5>Make anything a submit button. </h5><code>[data-vsubmit=1]</code>
</div>
</div>
</form>
</div>
</div>
</div>
<div class="row">
<div class='col-lg-12'>
<div class='panel'>
<div class='panel-heading'><h4 class='panel-title'>Valid values required <code>[data-vreq=1 data-vtype=*]</code></h4></div>
<form>
<div class='row'>
<div class='col-lg-4'>
<input id='firstname'
class='form-control input-md'
placeholder='Phone Number'
data-vtype='phone_CA'
data-vreq='1'/>
</div>
<div class='col-lg-8'>
<h5>This input requires a value, and requires of valid type. </h5><code>[data-vreq=1 data-vtype='phone_CA']</code>
<P>Tests for valid Canadian/North American Phone Number, try any of these:
<ul>
<li>+1(403) 999 9999</li>
<li>18005555555</li>
<li>1-403-999-9999</li>
<li>403-999-9999</li>
<li>780.999-9999</li>
<li>and any other way you can think of.</li>
</ul>
</p>
</div>
</div>
<BR>
<div class='row'>
<div class='col-lg-4'>
<input id='lastname'
class='form-control input-md'
placeholder='Email'
data-vreq='1'
data-vtype='email'/>
</div>
<div class='col-lg-8'>
<h5>Value required, and must be valid email. </h5><code>[data-vreq=1 data-vtype='email']</code>
</div>
</div>
<BR>
<div class='row'>
<div class='col-lg-4'>
<a
class='btn btn-md btn-primary'
data-vsubmit='1'
data-vfunc='doSomething'
data-vclear='1'>Submit</a>
</div>
<div class='col-lg-8'>
</div>
</div>
</form>
</div>
</div>
</div>
<div class="row">
<div class='col-lg-12'>
<div class='panel'>
<div class='panel-heading'><h4 class='panel-title'>Optional (but valid) values <code>[data-vreq=0 data-vtype=*]</code></h4></div>
<form>
<div class='row'>
<div class='col-lg-4'>
<input id='firstname'
class='form-control input-md'
placeholder='Phone Number (optional)'
data-vtype='phone_CA'
data-vreq='0'/>
</div>
<div class='col-lg-8'>
<h5>This input does not require a value, but if entered it must be valid. </h5><code>[data-vreq=0 data-vtype='phone_CA']</code>
</div>
</div>
<BR>
<div class='row'>
<div class='col-lg-4'>
<input id='lastname'
class='form-control input-md'
placeholder='Postal Code (optional)'
data-vreq='0'
data-vtype='postal_CA'/>
</div>
<div class='col-lg-8'>
<h5>This input does not require a value, but if entered must be valid. </h5><code>[data-vreq=0 data-vtype='postal_CA']</code>
<P>Tests for valid Canadian Postal Code, try any of these:
<ul>
<li>t4t4t4</li>
<li>T1W 4T9</li>
<li>t4t-4t4</li>
<li>V1Y.1W3</li>
<li>and any other way you can think of.</li>
</ul>
</p>
</div>
</div>
<BR>
<div class='row'>
<div class='col-lg-4'>
<a
class='btn btn-md btn-primary'
data-vsubmit='1'
data-vfunc='doSomething'
data-vclear='1'>Submit</a>
</div>
<div class='col-lg-8'>
</div>
</div>
</form>
</div>
</div>
</div>
<div class="row">
<div class='col-lg-12'>
<div class='panel'>
<div class='panel-heading'><h4 class='panel-title'>bootstrap-chosen select boxes <code>[data-vreq=*]</code></h4></div>
<form>
<div class='row'>
<div class='col-lg-4'>
<select class="chosen chosen-select-deselect"
id='province'
data-vreq='1'>
<option value=''></option>
<option value='AB'>Alberta</option>
<option value='BC'>British Columbia</option>
<option value='SK'>Saskatchewan</option>
<option value='MB'>Manitoba</option>
<option value='ON'>Ontario</option>
<option value='QC'>Quebec</option>
<option value='NB'>New Brunswick</option>
<option value='PE'>Prince Edward Island</option>
<option value='NL'>Newfoundland & Labrador</option>
<option value='NS'>Nova Scotia</option>
<option value='YK'>Yukon</option>
<option value='NW'>North-West Territories</option>
<option value='NT'>Nunavut</option>
</select>
</div>
<div class='col-lg-8'>
<h5>This input is required. Just add the <code>.chosen</code> class to the select box. </h5><code>[data-vreq=1]</code>
</div>
</div>
<BR>
<div class='row'>
<div class='col-lg-4'>
<a
class='btn btn-md btn-primary'
data-vsubmit='1'
data-vfunc='doSomething'
data-vclear='1'>Submit</a>
</div>
<div class='col-lg-8'>
</div>
</div>
</form>
</div>
</div>
</div>
<BR><BR>
<div class="row">
<div class='col-lg-12'>
<h4><a class="fork" href="https://github.com/cthiggo/validate">Fork on Github</a></h4>
</div>
</div>
</div>
<BR><BR><BR><BR>
<script type="text/javascript" src="jquery/jquery.min.js"></script>
<script type="text/javascript" src="bootstrap/bootstrap.min.js"></script>
<script type="text/javascript" src="validate.js"></script>
<script type="text/javascript" src="chosen-optional/chosen.jquery.min.js"></script>
<script type='text/javascript'>
/*
* Chosen Configuration & Initialization
*/
var config = {
'.chosen-select' : {},
'.chosen-select-deselect' : {allow_single_deselect:true},
'.chosen-select-no-single' : {disable_search_threshold:10},
'.chosen-select-no-results': {no_results_text:'Oops, nothing found!'},
'.chosen-select-width' : {width:"95%"}
}
for (var selector in config) {
$(selector).chosen(config[selector]);
}
$(window).load(function(){ //patch fix size of select box
$('.chosen-container').css('width', '100%');
});
</script>
</body>
</html>