forked from hueitan/angular-validation
/
index.html
356 lines (313 loc) · 17.1 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
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
<!doctype html>
<html ng-app="myApp">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width" />
<meta name="distribution" content="global" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="author" content="Huei Tan" />
<meta name="publisher" content="Huei Tan" />
<meta name="rating" content="general" />
<meta name="robots" content="all" />
<meta name="spiders" content="all" />
<meta name="webcrawlers" content="all" />
<meta name="company" content="angular-validation" />
<meta name="abstract" content="Client-side Validation for AngularJS" />
<!-- <link rel="SHORTCUT ICON" type="image/x-icon" href="/images/favicon.ico" sizes="16x16 24x24 32x32 48x48 64x64" />
<link rel="icon" type="image/x-icon" href="/images/favicon.ico" sizes="16x16 24x24 32x32 48x48 64x64" /> -->
<meta name="subject" content="angular-validation" />
<meta name="description" content="Client-side Validation for AngularJS" />
<meta name="keywords" content="angular","angularjs","validation","angular validation","validator","client-side" />
<meta property="og:title" content="angular-validation" />
<meta property="og:url" content="http://huei90.github.io/angular-validation/" />
<meta property="og:description" content="Client-side Validation for AngularJS" />
<meta property="og:image" content="//avatars0.githubusercontent.com/u/2560096?v=3&s=460" />
<title>Angular Validation</title>
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/foundation/5.2.2/css/foundation.min.css"/>
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.5/styles/solarized_light.min.css"/>
<link rel="stylesheet" href="demo/main.css"/>
</head>
<body ng-controller="index">
<div class="row">
<div class="small-12 medium-12 large-12 large-centered columns">
<h1>Angular Validation.
<small>
<a href="#form1">Watch</a>.
<a href="#form2">Blur</a>.
<a href="#form3">Submit</a>.
<a href="#form5">Submit-only</a>.
<!--method.-->
<a href="#form4">Additions</a>.
<!--validation-->
</small>
</h1>
</div>
</div>
<div class="row">
<div class="small-12 medium-12 large-12 columns">
<form name="Form">
<fieldset>
<legend>Getting Started</legend>
<div>
<label>Required</label>
<input type="text" name="required" ng-model="form.required" validator="required">
</div>
<div>
<label>Url</label>
<input type="text" name="url" ng-model="form.url" validator="required, url">
</div>
<button validation-submit="Form" ng-click="next()">Submit</button>
<button validation-reset="Form">Reset</button>
<button ng-click="showcode1 = !showcode1" class="button success">
<span ng-hide="showcode1">Show Code</span>
<span ng-show="showcode1">Hide Code</span>
</button>
<pre ng-show="showcode1"><code class="html"><form <span data-tooltip aria-haspopup="true" class="has-tip" title="define form name">name="Form"</span>>
<div>
<label>Required</label>
<input type="text" name="required" ng-model="form.required" <span data-tooltip aria-haspopup="true" class="has-tip" title="Choose validator type">validator="required"</span>>
</div>
<div>
<label>Url</label>
<input type="text" name="url" ng-model="form.url" <span data-tooltip aria-haspopup="true" class="has-tip" title="Multiple types of validator">validator="required, url"</span>>
</div>
<button <span data-tooltip aria-haspopup="true" class="has-tip" title="Submit Form">validation-submit="Form"</span> <span data-tooltip aria-haspopup="true" class="has-tip" title="execute next() if form submitted success">ng-click="next()"</span>>Submit</button>
<button <span data-tooltip aria-haspopup="true" class="has-tip" title="Reset Form">validation-reset="Form"</span>>Reset</button>
</form>
</code></pre>
</fieldset>
</form>
</div>
<div class="small-12 medium-12 large-12 columns">
<form name="Form" id="form1">
<fieldset>
<legend>Form ($watch)</legend>
<label>Email</label>
<input type="text"
name="emailWatch"
ng-model="form.email"
validator="email"
email-error-message="Error Email"
email-success-message="Good Email"
message-id="emailWatch"/>
<span id="emailWatch"></span>
<label>Number</label>
<input type="text"
name="numberWatch"
ng-model="form.number"
validator="number"
email-error-message="Error Number"
email-success-message="Good Number",
message-id="numberWatch"/>
<span id="numberWatch"></span>
<!-- <label>Required (Invalid Callback alert)</label>
<input type="text" name="requiredCallback" ng-model="form.requiredCallback" validator="required" invalid-callback='error("Must be Required");'/>
<label>IP address (Custom setup the new validator)</label>
<input type="text" name="ipWatch" ng-model="form.ip" validator="ip"/> -->
<button style="" ng-click="showcodewatch = !showcodewatch" class="button success">
<span ng-hide="showcodewatch">Show Code</span>
<span ng-show="showcodewatch">Hide Code</span>
</button>
<pre ng-show="showcodewatch"><code class="html"><!-- default valid-method is watch -->
<input type="text" name="emailBlur" ng-model="form.email" validator="email"/></code></pre>
</fieldset>
</form>
</div>
<div class="small-12 medium-12 large-12 columns">
<form name="Form2" id="form2">
<fieldset>
<legend>Form ($blur)</legend>
<label>Name</label>
<input type="text" name="requireBlur" ng-model="form2.required" validator="required" valid-method="blur"/>
<label>Email</label>
<input type="text" name="emailBlur" ng-model="form2.email" validator="email" valid-method="blur"/>
<button style="" ng-click="showcodeblur = !showcodeblur" class="button success">
<span ng-hide="showcodeblur">Show Code</span>
<span ng-show="showcodeblur">Hide Code</span>
</button>
<pre ng-show="showcodeblur"><code class="html"><input type="text" name="emailBlur" ng-model="form.email" validator="email" <span data-tooltip aria-haspopup="true" class="has-tip" title="valid method type set to blur">valid-method="blur"</span>/></code></pre>
</fieldset>
</form>
</div>
</div>
<div class="row">
<div class="small-12 medium-12 large-12 columns">
<form name="Form3" id="form3">
<fieldset>
<legend>Form ($submit with callback)</legend>
<label>Required</label>
<input type="text" name="requireSubmit" ng-model="form3.required" validator="required" valid-method="submit" message-id="requireSubmit"/>
<span id="requireSubmit"></span>
<label>Url</label>
<input type="text" name="urlSubmit" ng-model="form3.url" validator="url" valid-method="submit" message-id="urlSubmit"/>
<span id="urlSubmit"></span>
<label>Email</label>
<input type="text" name="emailSubmit" ng-model="form3.email" validator="email" valid-method="submit" message-id="emailSubmit"/>
<span id="emailSubmit"></span>
<label>Number</label>
<input type="text" name="numberSubmit" ng-model="form3.number" validator="number" valid-method="submit" message-id="numberSubmit"/>
<span id="numberSubmit"></span>
<ul class="button-group">
<li><button class="button" ng-click="form3.submit(Form3)">Submit</button></li>
<li><button class="button alert" ng-click="form3.reset(Form3)">Reset</button></li>
<li><button class="button secondary" ng-disabled="!form3.checkValid(Form3)">checkValid = {{ form3.checkValid(Form3) }}</button></li>
</ul>
</fieldset>
<!-- <pre>{{ form | json }}</pre> -->
</form>
</div>
<div class="small-12 medium-12 large-12 columns">
<form name="Form4" id="form4">
<fieldset>
<legend>Form (Additions validation)</legend>
<div class="row collapse">
<div class="small-9 columns">
<input type="text" validator="huei" name="huei" ng-model="form4.huei" placeholder="It's must be 'Huei Tan'" message-id="huei">
<span id="huei"></span>
</div>
<div class="small-3 columns">
<span class="postfix radius">With <a href="https://github.com/huei90/angular-validation#custom-function-huei" target="_blank">Function</a> </span>
</div>
</div>
<div class="row collapse">
<div class="small-7 columns">
<input type="text" validator="huei" name="noMsg" ng-model="form4.noMsg" no-validation-message="true" placeholder="It's must be 'Huei Tan'" message-id="noMsg">
<span id="noMsg"></span>
</div>
<div class="small-5 columns">
<span class="postfix radius">
<span ng-if="!Form4.noMsg.$valid">type: Huei Tan</span>
<span ng-if="Form4.noMsg.$valid"><a href="https://github.com/huei90/angular-validation#no-validation-message" target="_blank">no-validation-message</a></span>
</span>
</div>
</div>
<div class="row collapse">
<div class="small-7 columns">
<input type="text" validator="huei" name="canChange" huei-error-message="{{ form4.changeErrorMsg }}" ng-model="form4.canChange" placeholder="Type Wrong !!" message-id="canChange">
<span id="canChange"></span>
</div>
<div class="small-5 columns">
<span class="postfix radius">
<span ng-if="!form4.show"><a href="javascript:void(0);" ng-click="form4.changeMsg();form4.show = true;">Change Error Msg</a></span>
<span ng-if="form4.show">Type Again <a href="https://github.com/huei90/angular-validation/blob/master/demo/demo.js#L45" target="_blank">#</a></span>
</span>
</div>
</div>
<div class="row collapse">
<div class="small-12 columns">
<input type="text" validator="range" name="range" ng-model="form4.range" placeholder="number 5~10" min="5" max="10" message-id="range">
<span id="range"></span>
</div>
</div>
<div class="row collapse">
<div class="small-12 columns">
<input type="text" validator="required, range" name="multiple" ng-model="form4.multiple" placeholder='number 5~10 with required (validator="required, range")' min="5" max="10" message-id="multiple">
<span id="multiple"></span>
</div>
</div>
</fieldset>
</form>
</div>
</div>
<div class="row">
<div class="small-12 medium-12 large-12 columns">
<form name="Form5" id="form5">
<fieldset>
<legend>Form ($submit-only)</legend>
<label>Required</label>
<input type="text" name="emailRequiredOnly" ng-model="form5.required" validator="required" valid-method="submit-only" message-id="emailRequiredOnly"/>
<span id="emailRequiredOnly"></span>
<label>Email</label>
<input type="text" name="emailSubmitOnly" ng-model="form5.email" validator="email" valid-method="submit-only" message-id="emailSubmitOnly"/>
<span id="emailSubmitOnly"></span>
<label>Lucky Number</label>
<select class="form-control" name="selectBlur" ng-model="form5.select" validator="required" message-id="selectBlur">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>
<span id="selectBlur"></span>
<label>Checkbox</label>
<div class="large-12 columns">
<input id="checkbox1" type="checkbox" name="checkBlur" ng-model="form5.check" validator="required" message-id="checkBlur"/><label for="checkbox1">Checkbox 1</label>
<span id="checkBlur"></span>
</div>
<ul class="button-group">
<li><button class="button" ng-click="form5.submit(Form5)">Submit</button></li>
<li><button class="button alert" ng-click="form5.reset(Form5)">Reset</button></li>
<li><button class="button secondary" ng-disabled="!form5.checkValid(Form5)">checkValid = {{ form5.checkValid(Form5) }}</button></li>
</ul>
<!-- <pre>{{ form | json }}</pre> -->
</fieldset>
</form>
</div>
<div class="small-12 medium-12 large-12 columns">
<form name="Form6" id="form6">
<fieldset>
<legend>Form (ng-repeat)</legend>
<label>Required</label>
<div ng-repeat="a in form6.required">
<input type="text" name="emailRequiredOnly{{$index}}" ng-model="a.required" validator="required" message-id="emailRequiredOnly{{$index}}"/>
<span id="emailRequiredOnly{{$index}}"></span>
</div>
<blockquote ng-non-bindable>
In name attribute we have to use {{$index}}
<cite>eg. emailRequiredOnly{{$index}}</cite>
</blockquote>
<ul class="button-group">
<li><button class="button" validation-submit="Form6">Submit</button></li>
<li><button class="button alert" validation-reset="Form6">Reset</button></li>
<li><button class="button secondary" ng-disabled="!form6.checkValid(Form6)">checkValid = {{ form6.checkValid(Form6) }}</button></li>
</ul>
<!-- <pre>{{ form | json }}</pre> -->
</fieldset>
</form>
</div>
<div class="small-12 medium-12 large-12 columns">
<form style="text-align: center;">
<a href="//github.com/huei90/angular-validation/blob/master/API.md" target="_blank">
<fieldset>
More API Documentation
</fieldset>
</a>
<a href="//github.com/huei90/angular-validation/issues" target="_blank">
<fieldset>
Found a bug/issue?
</fieldset>
</a>
<a href="//github.com/huei90/angular-validation" target="_blank">
<fieldset>
Buy me a Star!
</fieldset>
</a>
</form>
</div>
</div>
<a href="https://github.com/huei90/angular-validation" target="_blank"><img src="demo/iconmonstr-github-10-icon-128.png" id="github-link" alt="Fork me on Github"/></a>
<script src="//cdnjs.cloudflare.com/ajax/libs/modernizr/2.8.3/modernizr.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.5/highlight.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/foundation/5.5.2/js/foundation.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/foundation/5.5.2/js/foundation/foundation.tooltip.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.18/angular.min.js"></script>
<script src="dist/angular-validation.js"></script>
<script src="dist/angular-validation-rule.js"></script>
<script src="demo/demo.js"></script>
<script>
hljs.initHighlightingOnLoad();
$(document).foundation();
</script>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-62825613-1', 'auto');
ga('send', 'pageview');
</script>
</body>
</html>