-
Notifications
You must be signed in to change notification settings - Fork 46
/
index.html
177 lines (169 loc) · 10.3 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
<!doctype html>
<html ng-app="app">
<head>
<meta charset="utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<title>angular-validator</title>
<link type="text/css" rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css"/>
<link type="text/css" rel="stylesheet" href="example/site.css"/>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.11/angular.min.js"></script>
<script type="text/javascript" src="dist/angular-validator.js"></script>
<script type="text/javascript" src="dist/angular-validator-rules.js"></script>
<script type="text/javascript" src="example/demo.js"></script>
</head>
<body class="container">
<div class="row">
<div class="col-md-12" ng-controller="DemoController">
<!-- $watch -->
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">$watch</h3>
</div>
<form name="formA" class="form-horizontal panel-body">
<div class="alert alert-danger" ng-if="formA.$invalid">Form Error!!</div>
<div class="alert alert-success" ng-if="!formA.$invalid">Form Success!!</div>
<div class="form-group">
<label for="required0" class="col-md-2 control-label">Required</label>
<div class="col-md-10">
<input type="text" ng-model="formWatch.required" validator="[required]" class="form-control" id="required0" placeholder="Required" autofocus/>
</div>
</div>
<div class="form-group">
<label for="regexp0" class="col-md-2 control-label">RegExp [a-z]</label>
<div class="col-md-10">
<input type="text" ng-model="formWatch.regexp" validator="/[a-z]/" validator-invoke="watch" validator-error="it should be /[a-z]/" class="form-control" id="regexp0" placeholder="RegExp [a-z]"/>
</div>
</div>
<div class="form-group">
<label for="number0" class="col-md-2 control-label">Number 1</label>
<div class="col-md-10">
<input type="text" ng-model="formWatch.number" validator="[required, number]" class="form-control" id="number0" placeholder="Number, Required"/>
</div>
</div>
<div class="form-group">
<label for="number20" class="col-md-2 control-label">Number 2</label>
<div class="col-md-10">
<input type="text" ng-model="formWatch.number2" validator="[number, customLess]" class="form-control" id="number20" placeholder="it should less than number 1"/>
</div>
</div>
<div class="form-group">
<label for="http0" class="col-md-2 control-label">$http</label>
<div class="col-md-10">
<input type="text" ng-model="formWatch.http" validator="[backendWatch]" class="form-control" id="http0" placeholder="do not use 'Kelp' or 'x'"/>
</div>
</div>
<div class="form-group">
<label for="requiredRun0" class="col-md-2 control-label">Required</label>
<div class="col-md-10">
<input type="text" ng-model="formWatch.requiredRun" validator="[requiredRun]" class="form-control" id="requiredRun0" placeholder="Required"/>
<span>The rule of this field is register in angular.module.run()</span><br/>
</div>
</div>
</form>
<div class="panel-footer">{{formWatch}}</div>
</div>
<!-- submit -->
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">submit</h3>
</div>
<form class="form-horizontal panel-body">
<div class="form-group">
<label for="required2" class="col-md-2 control-label">Required</label>
<div class="col-md-10">
<input type="text" ng-model="formSubmit.required" validator="[requiredSubmit]" class="form-control" id="required2" placeholder="Required"/>
</div>
</div>
<div class="form-group">
<label for="regexp2" class="col-md-2 control-label">RegExp [a-z]</label>
<div class="col-md-10">
<input type="text" ng-model="formSubmit.regexp" validator="/[a-z]/" validator-error="it should be /[a-z]/" class="form-control" id="regexp2" placeholder="RegExp [a-z]"/>
</div>
</div>
<div class="form-group">
<label for="number2" class="col-md-2 control-label">Number</label>
<div class="col-md-10">
<input type="text" ng-model="formSubmit.number" validator="[numberSubmit, requiredSubmit]" class="form-control" id="number2" placeholder="Number, Required"/>
</div>
</div>
<div class="form-group">
<label for="http2" class="col-md-2 control-label">$http</label>
<div class="col-md-10">
<input type="text" ng-model="formSubmit.http" validator="[backendSubmit]" class="form-control" id="http2" placeholder="do not use 'Kelp' or 'x'"/>
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" ng-click="formSubmit.submit()" class="btn btn-default"/>
<input type="button" ng-click="formSubmit.reset()" class="btn btn-default" value="Reset"/>
</div>
</div>
</form>
<div class="panel-footer">{{formSubmit}}</div>
</div>
<!-- blur -->
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">blur</h3>
</div>
<form class="form-horizontal panel-body">
<div class="form-group">
<label for="required1" class="col-md-2 control-label">Required</label>
<div class="col-md-10">
<input type="text" ng-model="formBlur.required" validator="[requiredBlur]" class="form-control" id="required1" placeholder="Required" />
</div>
</div>
<div class="form-group">
<label for="email1" class="col-md-2 control-label">Email</label>
<div class="col-md-10">
<input type="text" ng-model="formBlur.email" validator="[email]" class="form-control" id="email1" placeholder="Email" />
</div>
</div>
<div class="form-group">
<label for="url1" class="col-md-2 control-label">Url</label>
<div class="col-md-10">
<input type="text" ng-model="formBlur.url" validator="[url]" class="form-control" id="url1" placeholder="Url" />
</div>
</div>
<div class="form-group">
<label for="regexp1" class="col-md-2 control-label">RegExp [a-z]</label>
<div class="col-md-10">
<input type="text" ng-model="formBlur.regexp" validator="/[a-z]/" validator-invoke="blur" validator-error="it should be /[a-z]/" class="form-control" id="regexp1" placeholder="RegExp [a-z]"/>
</div>
</div>
<div class="form-group">
<label for="http1" class="col-md-2 control-label">$http</label>
<div class="col-md-10">
<input type="text" ng-model="formBlur.http" validator="[backendBlur]" class="form-control" id="http1" placeholder="do not use 'Kelp' or 'x'"/>
</div>
</div>
</form>
<div class="panel-footer">{{formBlur}}</div>
</div>
<!-- ng-repeat -->
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">ng-repeat</h3>
</div>
<form class="form-horizontal panel-body">
<div class="form-group" ng-repeat="item in formRepeat.model">
<label for="repeat{{$index}}" class="col-md-2 control-label">Number</label>
<div class="col-md-10">
<input type="text" ng-model="item.value" validator="[required, number]" class="form-control" id="repeat{{$index}}" placeholder="Required, Number" />
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" ng-click="formRepeat.submit()" class="btn btn-default"/>
<input type="button" ng-click="formRepeat.reset()" class="btn btn-default" value="Reset"/>
</div>
</div>
</form>
<div class="panel-footer">{{formRepeat}}</div>
</div>
</div>
</div>
<a href="https://github.com/kelp404/angular-validator" target="_blank"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_gray_6d6d6d.png" alt="Fork me on GitHub"></a>
</body>
</html>