-
Notifications
You must be signed in to change notification settings - Fork 12
/
index.html
206 lines (170 loc) · 6.31 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
<!DOCTYPE html>
<html>
<head>
<title>Bootstrap validate</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="/css/bootstrap.min.css" rel="stylesheet">
<script src="/js/jquery.js"></script>
<script src="/js/bootstrap.min.js"></script>
<script src="/js/bootstrap.validate.js"></script>
<script src="/js/bootstrap.validate.en.js"></script>
<style>
fieldset {
width: 220px;
padding: 18px;
margin: 200px auto 0px auto;
border: 1px solid silver;
border-radius: 8px;
}
fieldset legend {
padding: 0px 12px 0px 12px;
border: 1px solid silver;
width: auto;
border-radius: 8px;
}
fieldset form {
margin: 0px;
}
.cHeader {
cursor: pointer;
font-weight: bold;
}
.cPanel {
cursor: pointer;
color: blue;
text-decoration: underline;
display: none;
}
</style>
</head>
<body>
<script type="text/javascript">
$(document).ready(function() {
$('.cHeader').click(function() {
$(this).next().slideToggle();
});
$('.cPanel').click(function() {
$(this).slideToggle();
});
$('#bt_form').bt_validate();
$('#form_2').bt_validate();
$('#form_3').bt_validate();
//Custom check function
$.bt_validate.method(
'custom_pass_eq',
function(value) {
return ($('#pass').val() == $('#pass2').val());
},
"The passwords are not equal"
);
//Ajax check function
$.bt_validate.method(
'usercheck',
$.bt_validate.ajax_check({
url: '/usercheck.php',
type: 'POST',
return_type: 'text',
get_data: function() { return {'email': $('#email').val()} },
get_success: function(res) { return (res == '1'); },
msg_ok: 'This email is free',
msg_checking: 'Checking ...',
msg_fail: 'This email is olready used'})
);
$.bt_validate.after_validate = function(method, value, params, result) {
//this -> input field
//method -> validation method
//value -> value to validate;
//params -> method params (between,5,7)
//result -> validation result (true or false)
console.log(this, method, value, params, result);
}
});
</script>
<fieldset>
<legend>Bootstrap validate</legend>
<form method="post" id="bt_form">
<label for="required">Required</label>
<input name="required" id="required" type="text" validate="required"/>
<code> validate="required" </code>
<label for="required">Required (file)</label>
<input name="file" id="file" type="file" validate="required"/>
<code> validate="required" </code>
<label for="email">Email</label>
<input name="email" id="email" type="text" validate="email"/>
<code> validate="email" </code>
<label for="www">WWW</label>
<input name="www" id="www" type="text" validate="www"/>
<code> validate="www" </code>
<label for="date">Date</label>
<input name="date" id="date" type="text" validate="date"/>
<code> validate="date" </code>
<label for="time">Time</label>
<input name="time" id="time" type="text" validate="time"/>
<code> validate="time" </code>
<label for="datetime">Datetime</label>
<input name="datetime" id="datetime" type="text" validate="datetime"/>
<code> validate="datetime" </code>
<label for="number">Number</label>
<input name="number" id="number" type="text" validate="number"/>
<code> validate="number" </code>
<label for="float">Floating point number</label>
<input name="float" id="float" type="text" validate="float"/>
<code> validate="float" </code>
<label for="equal5">Equal 5</label>
<input name="equal5" id="equal5" type="text" validate="equal,5"/>
<code> validate="equal,5" </code>
<label for="min">Min 5</label>
<input name="min" id="min" type="text" validate="number|min,5"/>
<code> validate="number|min,5" </code>
<label for="max">Max 5</label>
<input name="max" id="max" type="text" validate="number|max,5"/>
<code> validate="number|max,5" </code>
<label for="between">Floating point between 5 and 7</label>
<input name="between" id="between" type="text" validate="float|between,5,7"/>
<code> validate="float|between,5,7" </code>
<label for="length_between">Stringth length between 5 and 7</label>
<input name="length_between" id="length_between" type="text" validate="length_between,5,7"/>
<code> validate="length_between,5,7" </code>
<label for="email">Ajax usercheck</label>
<input name="email" id="email" type="text" validate="required|email|usercheck"/>
<div class="cHeader">
This emails are used: </br>
</div>
<div class="cPanel">
[email protected] </br>
[email protected] </br>
[email protected] </br>
[email protected] </br>
[email protected] </br>
</div>
<code> validate="required|email|usercheck" </code>
<label for="pass">Password</label>
<input name="pass" id="pass" type="password" validate="length_min,5"/>
<code> validate="length_min,5" </code>
<label for="pass2">Repeat password</label>
<input name="pass2" id="pass2" type="password" validate="custom_pass_eq"/>
<code> validate="custom_pass_eq" </code>
<input class="btn pull-right" type="submit" value="Submit" name="submit"/>
</form>
</fieldset>
<fieldset>
<legend>Form #2</legend>
<form method="post" id="form_2">
<label for="required">Required</label>
<input name="required" id="required" type="text" validate="required"/>
<code> validate="required" </code>
<input class="btn pull-right" type="submit" value="Submit" name="submit"/>
</form>
</fieldset>
<fieldset>
<legend>Form #3</legend>
<form method="post" id="form_3">
<label for="required">Required</label>
<input name="required" id="required" type="text" validate="required"/>
<code> validate="required" </code>
<input class="btn pull-right" type="submit" value="Submit" name="submit"/>
</form>
</fieldset>
</body>
</html>