forked from hueitan/angular-validation
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
220 lines (187 loc) · 9.95 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
<!doctype html>
<html ng-app="myApp">
<head>
<title>Angular Validation</title>
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/foundation/5.0.2/css/foundation.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-6 columns">
<form name="Form" id="form1">
<fieldset>
<legend>Form ($watch)</legend>
<label>Required</label>
<input type="text"
name="requireWatch"
ng-model="form.required"
validator="required"
required-error-message="Required"
required-success-message="Good Required" autofocus="autofocus"/>
<label>Url</label>
<input type="text"
name="urlWatch"
ng-model="form.url"
validator="url"
url-error-message="Error Url"
url-success-message="Good Url"/>
<label>Email</label>
<input type="text"
name="emailWatch"
ng-model="form.email"
validator="email"
email-error-message="Error Email"
email-success-message="Good Email"/>
<label>Number</label>
<input type="text"
name="numberWatch"
ng-model="form.number"
validator="number"
email-error-message="Error Number"
email-success-message="Good Number"/>
<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"/>
</fieldset>
<ul class="button-group">
<li><button class="button" validation-submit="Form" ng-click="form.submit()">Submit</button></li>
<li><button class="button alert" validation-reset="Form" ng-click="form.reset()">Reset</button></li>
<li><button class="button secondary" ng-disabled="!form.checkValid(Form)">checkValid = {{ form.checkValid(Form) }}</button></li>
</ul>
<!--<pre>{{ form | json }}</pre>-->
</form>
</div>
<div class="small-12 medium-12 large-6 columns">
<form name="Form2" id="form2">
<fieldset>
<legend>Form ($blur)</legend>
<label>Required</label>
<input type="text" name="requireBlur" ng-model="form2.required" validator="required" valid-method="blur"/>
<label>Url</label>
<input type="text" name="urlBlur" ng-model="form2.url" validator="url" valid-method="blur"/>
<label>Email</label>
<input type="text" name="emailBlur" ng-model="form2.email" validator="email" valid-method="blur"/>
<label>Number</label>
<input type="text" name="numberBlur" ng-model="form2.number" validator="number" valid-method="blur"/>
</fieldset>
<ul class="button-group">
<li><button class="button" ng-click="form2.submit(Form2)">Submit</button></li>
<li><button class="button alert" ng-click="form2.reset(Form2)">Reset</button></li>
<li><button class="button secondary" ng-disabled="!form2.checkValid(Form2)">checkValid = {{ form2.checkValid(Form2) }}</button></li>
</ul>
<!-- <pre>{{ form | json }}</pre> -->
</form>
</div>
</div>
<div class="row">
<div class="small-12 medium-12 large-6 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"/>
<label>Url</label>
<input type="text" name="urlSubmit" ng-model="form3.url" validator="url" valid-method="submit"/>
<label>Email</label>
<input type="text" name="emailSubmit" ng-model="form3.email" validator="email" valid-method="submit"/>
<label>Number</label>
<input type="text" name="numberSubmit" ng-model="form3.number" validator="number" valid-method="submit"/>
</fieldset>
<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>
<!-- <pre>{{ form | json }}</pre> -->
</form>
</div>
<div class="small-12 medium-12 large-6 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'">
</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'">
</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 !!">
</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">
</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">
</div>
</div>
</fieldset>
</form>
</div>
</div>
<div class="row">
<div class="small-12 medium-12 large-6 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"/>
<label>Email</label>
<input type="text" name="emailSubmitOnly" ng-model="form5.email" validator="email" valid-method="submit-only"/>
</fieldset>
<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 = {{ form2.checkValid(Form2) }}</button></li>
</ul>
<!-- <pre>{{ form | json }}</pre> -->
</form>
</div>
</div>
<a href="https://github.com/huei90/angular-validation"><img src="demo/iconmonstr-github-10-icon-128.png" id="github-link" alt="Fork me on Github"/></a>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.1/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>
</body>
</html>