-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathbasic.html
executable file
·271 lines (261 loc) · 12 KB
/
basic.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
<!DOCTYPE html>
<html lang="en">
<head>
<title>Wizard plugin - FormValidation</title>
<meta charset="utf-8" />
<meta content="width=device-width,initial-scale=1" name="viewport" />
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"
/>
<link rel="stylesheet" href="https://unpkg.com/tachyons@4.10.0/css/tachyons.min.css" />
<link rel="stylesheet" href="/vendors/@form-validation/umd/styles/index.min.css" />
</head>
<body>
<form id="demoForm" method="POST">
<div class="js-step">
<div class="cf mb2">
<div class="fl w-100">
<div class="fl w-25 pa2">Quantity</div>
<div class="fl w-40">
<input type="text" class="input-reset ba b--black-20 pa2 mb2 db w-100" name="quantity" />
</div>
</div>
</div>
<div class="cf mb2">
<div class="fl w-100">
<div class="fl w-25 pa2">Size</div>
<div class="fl w-50">
<div class="mb2">
<label><input type="checkbox" name="size[]" value="s" /> S</label>
</div>
<div class="mb2">
<label><input type="checkbox" name="size[]" value="m" /> M</label>
</div>
<div class="mb2">
<label><input type="checkbox" name="size[]" value="l" /> L</label>
</div>
<div class="mb2">
<label><input type="checkbox" name="size[]" value="xl" /> XL</label>
</div>
</div>
</div>
</div>
<div class="cf mb2">
<div class="fl w-100">
<div class="fl w-25 pa2">Color</div>
<div class="fl w-50">
<div class="mb2">
<label><input type="checkbox" name="color[]" value="white" /> White</label>
</div>
<div class="mb2">
<label><input type="checkbox" name="color[]" value="black" /> Black</label>
</div>
<div class="mb2">
<label><input type="checkbox" name="color[]" value="red" /> Red</label>
</div>
<div class="mb2">
<label><input type="checkbox" name="color[]" value="yellow" /> Yellow</label>
</div>
<div class="mb2">
<label><input type="checkbox" name="color[]" value="green" /> Green</label>
</div>
</div>
</div>
</div>
</div>
<div class="js-step">
<div class="cf mb2">
<div class="fl w-100">
<div class="fl w-25 pa2">Full name</div>
<div class="fl w-30 mr2">
<input
type="text"
class="input-reset ba b--black-20 pa2 mb2 db w-100"
name="firstName"
placeholder="First name"
/>
</div>
<div class="fl w-30">
<input
type="text"
class="input-reset ba b--black-20 pa2 mb2 db w-100"
name="lastName"
placeholder="Last name"
/>
</div>
</div>
</div>
<div class="cf mb2">
<div class="fl w-100">
<div class="fl w-25 pa2">Phone number</div>
<div class="fl w-40">
<input type="text" class="input-reset ba b--black-20 pa2 mb2 db w-100" name="cellPhone" />
</div>
</div>
</div>
<div class="cf mb2">
<div class="fl w-100">
<div class="fl w-25 pa2">Street</div>
<div class="fl w-75">
<input type="text" class="input-reset ba b--black-20 pa2 mb2 db w-100" name="street" />
</div>
</div>
</div>
<div class="cf mb2">
<div class="fl w-100">
<div class="fl w-25 pa2">City</div>
<div class="fl w-40">
<input type="text" class="input-reset ba b--black-20 pa2 mb2 db w-100" name="city" />
</div>
</div>
</div>
<div class="cf mb2">
<div class="fl w-100">
<div class="fl w-25 pa2">Zipcode</div>
<div class="fl w-40">
<input type="text" class="input-reset ba b--black-20 pa2 mb2 db w-100" name="zipCode" />
</div>
</div>
</div>
</div>
<div class="cf mb2">
<div class="fl w-100">
<div class="fl w-25 pa2"></div>
<div class="fl w-50">
<button type="button" class="ba b--black-20 bg-blue white ph3 pv2 br2" id="prevButton">
Prev
</button>
<button type="button" class="ba b--black-20 bg-blue white ph3 pv2 br2" id="nextButton">
Next
</button>
</div>
</div>
</div>
</form>
<!--
You have to include the full version of FormValidation which contains all validators
including the phone and zipCode validators
-->
<script src="/vendors/@form-validation/umd/bundle/full.min.js"></script>
<script src="/vendors/@form-validation/umd/plugin-tachyons/index.min.js"></script>
<script src="/vendors/@form-validation/umd/plugin-wizard/index.min.js"></script>
<script>
document.addEventListener('DOMContentLoaded', function (e) {
FormValidation.formValidation(document.getElementById('demoForm'), {
fields: {
quantity: {
validators: {
notEmpty: {
message: 'The quantity is required',
},
greaterThan: {
min: 1,
message: 'The quantity must be greater than 0',
},
integer: {
message: 'The quantity must be a number',
},
},
},
'size[]': {
validators: {
notEmpty: {
message: 'The size is required',
},
},
},
'color[]': {
validators: {
notEmpty: {
message: 'The color is required',
},
},
},
firstName: {
validators: {
notEmpty: {
message: 'The first name is required',
},
regexp: {
regexp: /^[a-zA-Z\s]+$/,
message: 'The first name can only consist of alphabetical and space',
},
},
},
lastName: {
validators: {
notEmpty: {
message: 'The last name is required',
},
regexp: {
regexp: /^[a-zA-Z\s]+$/,
message: 'The last name can only consist of alphabetical and space',
},
},
},
cellPhone: {
validators: {
notEmpty: {
message: 'The phone number is required',
},
phone: {
country: 'US',
message: 'The value is not valid US phone number',
},
},
},
street: {
validators: {
notEmpty: {
message: 'The street is required',
},
},
},
city: {
validators: {
notEmpty: {
message: 'The city is required',
},
},
},
zipCode: {
validators: {
notEmpty: {
message: 'The zip code is required',
},
zipCode: {
country: 'US',
message: 'The value is not valid US zip code',
},
},
},
},
plugins: {
trigger: new FormValidation.plugins.Trigger(),
tachyons: new FormValidation.plugins.Tachyons(),
wizard: new FormValidation.plugins.Wizard({
stepSelector: '.js-step',
prevButton: '#prevButton',
nextButton: '#nextButton',
}),
submitButton: new FormValidation.plugins.SubmitButton(),
icon: new FormValidation.plugins.Icon({
valid: 'fa fa-check',
invalid: 'fa fa-times',
validating: 'fa fa-refresh',
}),
},
})
// Update the label of Next button
.on('plugins.wizard.step.active', function (e) {
document.getElementById('nextButton').innerHTML =
e.step === e.numSteps - 1 ? 'Purchase' : 'Next';
})
.on('plugins.wizard.valid', function (e) {
document.getElementById('nextButton').innerHTML = 'Done';
});
});
</script>
</body>
</html>