This repository has been archived by the owner on Feb 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
325 lines (322 loc) · 18.9 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Validation documentation</title>
<link rel="stylesheet" href="css/printdeal-fr-responsive-1.64.0.css">
<link rel="stylesheet" href="css/registration.css">
<link rel="stylesheet" href="css/validation-documentation.css">
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/lodash.js/3.5.0/lodash.min.js"></script>
<script src="https://s3-eu-west-1.amazonaws.com/printdealcdn/js/printdeal-1.53.0.js"></script>
<script src="validation/validation.js"></script>
<script src="validation/input-validation.js"></script>
</head>
<body>
<div class="page-wrap">
<main role="main" id="main-content">
<section class="Panel Panel--IsResponsive Island">
<div class="row">
<div class="init-12 small-8 medium-12 cols">
<h1 class="h h1">Validation documentation</h1>
<p class="Island">Add these scripts at the bottom of the body:</p>
<div class="Panel Island">
<pre><code><script src="validation/validation.js"></script>
<script src="validation/input-validation.js"></script></code></pre>
</div>
<p class="Island">Enable validation on your form by adding the following script after the relevant dom elements have loaded (replace "formId" with an actual form id): </p>
<div class="Panel Island">
<pre><code>var form = document.getElementById('formId');
var validation = new Validation(form);</code></pre>
</div>
<h2 class="h h2 Island">Index</h2>
<ul>
<li>
<a href="#configuration-options">Configuration options</a>
</li>
<li>
<a href="validation-examples">Validation examples</a>
<ul>
<li>
<a href="#plain-example">Plain example</a>
</li>
<li>
<a href="#required-example">Required example</a>
</li>
<li>
<a href="#select-example">Select example</a>
</li>
<li>
<a href="#form-hints-example">Form hints example</a>
</li>
<li>
<a href="#no-icons-example">No icons example</a>
</li>
<li>
<a href="#no-auto-validation-example">No auto validation example</a>
</li>
</ul>
</li>
</ul>
</div>
</div>
</section>
<section class="Panel Panel--IsResponsive Island">
<div class="row">
<div class="init-12 small-8 medium-12 cols">
<header class="Island">
<h1 id="configuration-options" class="h h1">Configuration options</h1>
</header>
<table class="Island">
<thead>
<tr>
<th>Type</th>
<th>Name</th>
<th>Default</th>
</tr>
</thead>
<tbody>
<tr>
<td>boolean</td>
<td>auto</td>
<td>true</td>
</tr>
<tr>
<td>boolean</td>
<td>showIcons</td>
<td>true</td>
</tr>
<tr>
<td>boolean</td>
<td>showHints</td>
<td>this.$hint.length</td>
</tr>
<tr>
<td>string</td>
<td>successIcon</td>
<td>'<i class="Overlay Overlay--Right ValidationTargetIcon ValidationTargetIcon--Success Overlay--CenterY Icon Icon--Check--Green" aria-hidden="true"></i>'</td>
</tr>
<tr>
<td>string</td>
<td>errorIcon</td>
<td>'<i class="Overlay Overlay--Right ValidationTargetIcon ValidationTargetIcon--Error Overlay--CenterY Icon Icon--CrossCircle--Red" aria-hidden="true"></i>'</td>
</tr>
<tr>
<td>string</td>
<td>wrap</td>
<td>'<div class="HasOverlay"></div>'</td>
</tr>
<tr>
<td>boolean</td>
<td>hasErrorHint</td>
<td>this.$input.is('[data-validation-error]')</td>
</tr>
<tr>
<td>string</td>
<td>defaultHint</td>
<td>''</td>
</tr>
<tr>
<td>string</td>
<td>errorHint</td>
<td>''</td>
</tr>
<tr>
<td>boolean</td>
<td>hasDefaultHint</td>
<td>this.$input.is('[data-validation-default]')</td>
</tr>
<tr>
<td>boolean</td>
<td>hasDataConfig</td>
<td>this.$input.is('[data-validation-config]')</td>
</tr>
</tbody>
</table>
</div>
</div>
</section>
<section class="Panel Panel--IsResponsive Island">
<div class="row">
<div class="init-12 small-8 medium-12 cols">
<header class="Island">
<h1 id="validation-examples" class="h h1">Validation examples</h1>
</header>
<article>
<h2 id="plain-example" class="h h2 Island">Plain example</h2>
<p class="Island">Basic validation does not ever show error but shows success when a user has entered something. This is to provide positive feedback.</p>
<form id="form_example_plain" action="#">
<div class="row">
<div class="init-12 small-3 medium-3 cols">
<label for="input_example_plain" class="Form__Hint">Enter anything to check:</label>
</div>
<div class="init-12 small-9 medium-9 cols">
<input id="input_example_plain" type="text">
</div>
</div>
</form>
<script>
var formExamplePlain = document.getElementById('form_example_plain');
var validationPlain = new Validation(formExamplePlain);
</script>
</article>
<hr>
<article>
<h2 id="required-example" class="h h2 Island">Required example</h2>
<p class="Island">Add the attribute "required" to the inputs that are mandatory. Checks if the input is has a value (after trim).</p>
<p class="Island">
<code class="Mark--LightGray">required</code>
</p>
<form id="form_example_required" action="#">
<div class="row">
<div class="init-12 small-3 medium-3 cols">
<label for="input_example_required" class="Form__Hint">Enter anything or leave empty to check:</label>
</div>
<div class="init-12 small-9 medium-9 cols">
<input id="input_example_required" type="text" required>
</div>
</div>
</form>
<script>
var formExampleRequired = document.getElementById('form_example_required');
var validationRequired = new Validation(formExampleRequired);
</script>
</article>
<hr>
<article>
<h2 id="pattern-example" class="h h2 Island">Pattern example</h2>
<p class="Island">Add a pattern attribute to match against a regular expression.</p>
<p class="Island">
<code class="Mark--LightGray">pattern="^1234AB$"</code>
</p>
<form id="form_example_pattern" action="#">
<div class="row">
<div class="init-12 small-3 medium-3 cols">
<label for="input_example_pattern" class="Form__Hint">Enter 1234AB or 1234 to check:</label>
</div>
<div class="init-12 small-9 medium-9 cols">
<input id="input_example_pattern" type="text" pattern="^1234AB$">
</div>
</div>
</form>
<script>
var formExamplePattern = document.getElementById('form_example_pattern');
var validationPattern = new Validation(formExamplePattern);
</script>
</article>
<hr>
<article>
<h2 id="select-example" class="h h2 Island">Select example</h2>
<p class="Island">Select inputs act similar to plain inputs, if user changes or blurs the input it shows as success to provide positive feedback.</p>
<form id="form_example_select" action="#">
<div class="row">
<div class="init-12 small-3 medium-3 cols">
<label for="input_example_select" class="Form__Hint">Select anything to check:</label>
</div>
<div class="init-12 small-9 medium-9 cols">
<select id="input_example_select">
<option value="foo" selected>Foo</option>
<option value="bar">Bar</option>
</select>
</div>
</div>
</form>
<script>
var formExampleSelect = document.getElementById('form_example_select');
var validationSelect = new Validation(formExampleSelect);
</script>
</article>
<hr>
<article>
<h2 id="form-hints-example" class="h h2 Island">Form hints example</h2>
<p class="Island">A required validation with default and error hints.</p>
<p class="Island">Uses <code class="Mark--LightGray">data-validation-default="Default hint."</code> and <code class="Mark--LightGray">data-validation-error="Error hint."</code> attributes on the input and <code class="Mark--LightGray">data-validation-hint-for="input_example_hints"</code> on the form hint.</p>
<form id="form_example_hints" action="#">
<div class="row">
<div class="init-12 small-3 medium-3 cols">
<label for="input_example_hints" class="Form__Hint">Enter anything or leave empty to check:</label>
</div>
<div class="init-12 small-6 medium-6 cols">
<input id="input_example_hints" type="text" data-validation-default="Default hint." data-validation-error="Error hint." required>
</div>
<div class="init-12 small-3 medium-3 cols">
<small class="Form__Hint" data-validation-hint-for="input_example_hints">Default hint.</small>
</div>
</div>
</form>
<script>
var formExampleHints = document.getElementById('form_example_hints');
var validationHints = new Validation(formExampleHints);
</script>
</article>
<hr>
<article>
<h2 id="no-icons-example" class="h h2 Island">No icons example</h2>
<p class="Island">A required validation without icons.</p>
<p class="Island">
<code class="Mark--LightGray">data-validation-config='{"showIcons":false}'</code>
</p>
<form id="form_example_no_icons" action="#">
<div class="row">
<div class="init-12 small-3 medium-3 cols">
<label for="input_example_no_icons" class="Form__Hint">Enter anything or leave empty to check:</label>
</div>
<div class="init-12 small-9 medium-9 cols">
<input id="input_example_no_icons" type="text" data-validation-config='{"showIcons":false}' required>
</div>
</div>
</form>
<script>
var formExampleNoIcons = document.getElementById('form_example_no_icons');
var validationNoIcons = new Validation(formExampleNoIcons);
</script>
</article>
<hr>
<article>
<h2 id="no-auto-validation-example" class="h h2 Island">No auto validation example</h2>
<p class="Island">A required validation that does not automatically validate. In this case a button is used to validate.</p>
<p class="Island">
<code class="Mark--LightGray">data-validation-config='{"auto":false}'</code>
</p>
<div class="Panel Island">
<pre>
<code>var formExampleNoAuto = document.getElementById('form_example_no_auto');
var validationNoAuto = new Validation(formExampleNoAuto);
$('#button_no_auto').on('click', function (e) {
e.preventDefault();
document.getElementById('input_example_no_auto').inputValidation.validateRequired();
});</code>
</pre>
</div>
<form id="form_example_no_auto" action="#">
<div class="row">
<div class="init-12 small-3 medium-3 cols">
<label for="input_example_no_auto" class="Form__Hint">Click button to check if empty:</label>
</div>
<div class="init-12 small-9 medium-9 cols">
<input id="input_example_no_auto" type="text" data-validation-config='{"auto":false}' required>
</div>
</div>
<div class="row">
<div class="init-12 small-9 medium-9 small-offset-3 medium-offset-3 cols">
<button id="button_no_auto" class="Btn">Click me!</button>
</div>
</div>
</form>
<script>
var formExampleNoAuto = document.getElementById('form_example_no_auto');
var validationNoAuto = new Validation(formExampleNoAuto);
$('#button_no_auto').on('click', function(e) {
e.preventDefault();
document.getElementById('input_example_no_auto').inputValidation.validateRequired();
});
</script>
</article>
</div>
</div>
</section>
</main>
</div>
</div>
</body>
</html>