forked from guillaumepotier/Parsley.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
documentation.html
1553 lines (1468 loc) · 78.5 KB
/
documentation.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
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Parsley.js Documentation & API</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="Keywords" content="javascript form validation, javascript, form, validation, jquery, plungin, html, UX">
<meta name="description" content="Parsley is a dead simple javascript form validation, powerful and UX aware">
<meta name="author" content="Guillaume Potier">
<!-- Le styles -->
<link href="bower_components/bootstrap/docs/assets/css/bootstrap.css" rel="stylesheet" />
<link href="http://yandex.st/highlightjs/7.3/styles/github.min.css" rel="stylesheet" />
<style type="text/css">
body {
padding-top: 20px;
padding-bottom: 40px;
}
h3.muted {
color: #08C;
}
/* Custom container */
.container-narrow {
margin: 0 auto;
max-width: 940px;
}
.container-narrow > hr {
margin: 30px 0;
}
/* Main marketing message and sign up button */
.jumbotron {
margin: 60px 0;
text-align: center;
}
.jumbotron h1 {
font-size: 72px;
line-height: 1;
}
.jumbotron .btn {
font-size: 21px;
padding: 14px 24px;
}
section {
margin-bottom: 45px;
}
form {
margin: 0;
}
input.parsley-success, textarea.parsley-success {
color: #468847 !important;
background-color: #DFF0D8 !important;
border: 1px solid #D6E9C6 !important;
}
input.parsley-error, textarea.parsley-error {
color: #B94A48 !important;
background-color: #F2DEDE !important;
border: 1px solid #EED3D7 !important;
}
input {
width: 150px;
margin: 0 2px !important;
}
ul.parsley-error-list {
font-size: 11px;
margin: 2px;
list-style-type:none;
}
ul.parsley-error-list li {
line-height: 11px;
}
.social-buttons {
padding: 5px 20px;
}
h3 {
color: #FB4006;
}
.container-narrow > hr {
margin:15px 0 0 0;
}
@media only screen
and (min-device-width : 320px)
and (max-device-width : 480px) {
.not-for-mobile {
display: none;
}
}
</style>
<link href="bower_components/bootstrap/docs/assets/css/bootstrap-responsive.css" rel="stylesheet" />
<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<a href="https://github.com/guillaumepotier/Parsley.js"><img style="position: fixed; top: 0; right: 0; border: 0; z-index:9999" src="https://s3.amazonaws.com/github/ribbons/forkme_right_orange_ff7600.png" alt="Fork me on GitHub"></a>
<div class="container-narrow">
<div class="masthead">
<ul class="nav nav-pills pull-right">
<li><a href="index.html">Home</a></li>
<li class="active"><a href="documentation.html">Documentation</a></li>
<li><a href="doc/api/index.html" target="_blank">API</a></li>
</ul>
<h3 class="muted">
Parsley.js
<span class="social-buttons inline-block">
<a href="https://twitter.com/share" class="twitter-share-button" parsley-related="garlicjs: auto persist form values to avoid data loss,guillaumepotier" parsley-url="http://parsleyjs.org" parsley-lang="en" parsley-text="Parsley.js: never write a single javascript line anymore to validate your forms FrontEnd. #ui #ux #javascript"></a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
<iframe src="http://ghbtns.com/github-btn.html?user=guillaumepotier&repo=Parsley.js&type=watch&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="110" height="20"></iframe>
<iframe src="http://ghbtns.com/github-btn.html?user=guillaumepotier&repo=Parsley.js&type=fork&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="110" height="20"></iframe>
</span>
</h3>
</div>
<hr>
<div class="row-fluid marketing">
<h2>Demonstration</h2>
<a name="parsleydemoform"></a>
<table id="demonstration-form" class="table table-striped table-bordered table-hover">
<thead>
<tr>
<th width="27%">Classy demo</th>
<th width="73%" class="not-for-mobile">HTML Code (yes, no JS !)</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<form id="demo-form" no-validate>
<label for="fullname">Full Name * :</label>
<input type="text" id="fullname" name="fullname" required />
<label for="email">Email * :</label>
<input type="email" id="email" name="email" parsley-trigger="change" required />
<label for="website">Website :</label>
<input type="text" id="website" name="website" parsley-trigger="change" parsley-type="url" />
<label for="message">Message (20 chars min, 200 max) :</label>
<textarea id="message" name="message" parsley-trigger="keyup" parsley-rangelength="[20,200]"></textarea>
<input type="hidden" name="superhidden" id="superhidden">
<br/><span class="btn btn" id="demo-form-valid" onclick="javascript:$('#demo-form').parsley( 'validate' );"><i class="icon-ok"></i></span>
</form>
<small>Please, note that this demo form is not a perfect example of UX-awareness. The aim here is to show a quick overview of parsley-API and Parsley customizable behavior.</small>
</td>
<td class="not-for-mobile">
<pre><code><form id="demo-form" parsley-validate>
<label for="fullname">Full Name * :</label>
<input type="text" name="fullname" required />
<label for="email">Email * :</label>
<input type="email" name="email" parsley-trigger="change" required />
<label for="website">Website :</label>
<input type="text" name="website" parsley-trigger="change" parsley-type="url" />
<label for="message">Message (20 chars min, 200 max) :</label>
<textarea name="message" parsley-trigger="keyup" parsley-rangelength="[20,200]"></textarea>
</form></code></pre>
</td>
</tr>
</table>
<div class="alert alert-block alert-info">
<span class="label label-important">Heads up!</span> <strong>Le #UX touch</strong>:
<ul>
<li>
<strong>Min char validation</strong>: Parsley by default <strong>does not proceed with field validation when less than 3 chars have been input</strong>. Do not assault your users with error messages too soon! <i>(this behavior is configurable)</i>.
</li>
<li>
<strong>Quick error removal</strong>: when a field is detected and shown as invalid, further checks are done on each keypress to try to <strong>quickly remove error messages once the field is ok</strong>.
</li>
<li>
<strong>Control focusing on error</strong>: on form submission, the first error field is focused to <strong>allow the user to easily start fixing errors</strong>. <i>(this behavior is configurable)</i>
</li>
</ul>
</div>
<hr>
<a name="top"></a>
<h2>Documentation</h2>
<ol>
<li><a href="#installation"><strong>Installation & usage</strong>: one or two inclusions!</a></li>
<li><a href="#parsleyform"><strong>Parsley Form</strong>: add some Parsley validation to your forms!</a></li>
<li><a href="#parsleyfield"><strong>Parsley Field</strong>: customize each validated field validation behavior </a></li>
<li>
<a href="#validators"><strong>Validators</strong>: learn the various validations you could do with Parsley</a>
<ol>
<li><a href="#basic-constraints">Basic constraints</a></li>
<li><a href="#type-constraints">Type constraints</a></li>
<li><a href="#extra-constraints">Extra constraints</a></li>
</ol>
</li>
<li>
<a href="#javascript"><strong>Javascript</strong>: yes, you still can do some javascript with Parsley. Intermediate level only!</a>
<ol>
<li><a href="#javascript-general">General</a></li>
<li><a href="#javascript-form">Form</a></li>
<li><a href="#javascript-fields">Fields</a></li>
</ol>
</li>
<li>
<a href="#parsleyclasses"><strong>Parsley CSS</strong>: last but not least, Parsley CSS classes</a>
</li>
<li>
<a href="#plugins-and-localization"><strong>Plugins & Localization</strong>: extend Parsley messages, validators, templates and more!</a>
</li>
<li>
<a href="#integrations"><strong>Integrations</strong>: Use parsley from other frameworks.
</li>
<li>
<a href="#support"><strong>Support</strong>: How to find some useful help about Parsley on the Web..
</li>
</ol>
<hr>
<!-- //////////////////////////////////////////////////////////////////////////////////////////////////// -->
<section>
<a name="installation"></a>
<h3>Parsley Installation</h3>
<p>Just include the <a href="https://github.com/guillaumepotier/Parsley.js/blob/master/dist/parsley.min.js">Parsley.js</a> file (with <a href="http://jquery.com/">jQuery</a> or <a href="http://zeptojs.com/">Zepto</a> with <strong><a href="https://github.com/madrobby/zepto#building">data and fx_methods modules</a></strong> added)</p>
<pre><code><script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="parsley.js"></script>
<form parsley-validate>
[...]
</form></code></pre>
<div class="alert alert-block alert-info">
<span class="label label-important">Heads up!</span> <strong>W3C standards</strong>:
Parsley by default use <code>parsley-</code> API, which is so nice and simple, but absolutely not W3C valid. This is a personal choice, deal with it :) But, if you really want to be W3C compliant, feel free to configure your own DOM-API namespace by overriding Parsley default configs or using <code>data-parsley-namespace="data-parsley-"</code> and use <code>data-parsley-validate</code> to auto bind forms. (see below)
</div>
</section>
<a href="#top" class="top pull-right">Top</a>
<!-- //////////////////////////////////////////////////////////////////////////////////////////////////// -->
<section>
<a name="parsleyform"></a>
<h3>Parsley Form</h3>
<p>This is the main Parsley form validation factory, where you decide if a form is validated, and set some extra options.</p>
<pre><code><form parsley-validate></form></code></pre>
<div class="alert alert-block alert-info">
<span class="label label-important">Heads up!</span> <strong>HTML5</strong>:
If you use HTML5 types and want to disable HTML5 native browser validation, add a <code>novalidate</code> attribute to <code>form</code> tag.
If you want to prevent parsley from using any HTML5 validation attributes you can disable it by setting the <code>useHtml5Constraints</code> flag to false in the advanced configuration options, or using <code>parsley-use-html5-constraints="false"</code> in DOM.
</div>
<h4>Properties</h4>
<table class="table table-striped table-bordered table-hover">
<thead>
<tr>
<th>Property</th>
<th>Default</th>
<th>Description</th>
<th class="not-for-mobile">Demonstration</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>data-parsley-namespace</code></td>
<td>parsley-</td>
<td>Choose the DOM-API you want to use for Parsley.</td>
<td class="not-for-mobile"></td>
</tr>
<tr>
<td>
<code>parsley-validate</code><br/>
<code>data-parsley-validate</code>
</td>
<td></td>
<td>Bind Parsley validation to the form and its items with validation constraints</td>
<td class="not-for-mobile"></td>
</tr>
<tr>
<td><code>parsley-use-html5-constraints</code></td>
<td>true</td>
<td>Bind or not supported HTML5 tags</td>
<td class="not-for-mobile"></td>
</tr>
<tr>
<td><code>parsley-show-errors</code></td>
<td>true</td>
<td>Choose to show or not Parsley error messages & success / errors classes</td>
<td class="not-for-mobile"></td>
</tr>
<tr>
<td>
<code>parsley-focus</code>
</td>
<td>
first
</td>
<td>
Specify which field will be focused first on form validation errors. <code>first</code>, <code>last</code> and <code>none</code> allowed
</td>
<td class="not-for-mobile">
<table>
<tr>
<td>
<form parsley-validate id="focus-form" parsley-focus="last">
<p><input type="text" parsley-type="email" parsley-required="true" placeholder="won't have focus" /><p>
<p><input type="text" parsley-type="email" parsley-required="true" placeholder="will have focus" /></p>
</form>
</td>
<td>
<span class="btn btn-small" onclick="javascript:$('#focus-form').parsley('validate');">
<i class="icon-ok"></i>
</span>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td><code>parsley-bind</code></td>
<td></td>
<td>The attribute parsley-validate must be used on a form. However, if you want to bind the validation to a DOM element other than a form, just add this attribute.
<pre><code><div parsley-validate parsley-bind>
<input type="text" parsley-type="email" />
</div></code></pre>
</td>
<td></td>
</tr>
</tbody>
</table>
</section>
<a href="#top" class="top pull-right">Top</a>
<!-- //////////////////////////////////////////////////////////////////////////////////////////////////// -->
<section>
<a name="parsleyfield"></a>
<h3>Parsley Field</h3>
<p>Once your form is validated by Parsley, add validation constraints and various other options.</p>
<pre><code><form parsley-validate>
<input type="text" name="email" parsley-type="email" />
</form></code></pre>
<h4>Properties</h4>
<table class="table table-striped table-bordered table-hover">
<thead>
<tr>
<th>Property</th>
<th>Default</th>
<th>Description</th>
<th class="not-for-mobile">Demonstration</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<code>parsley-trigger</code>
</td>
<td>none</td>
<td>Specify one or many javascript events that will trigger item validation. eg: <code>parsley-trigger="change"</code>. To set multiple events, separate them by a space <code>parsley-trigger="focusin focusout"</code>.<br/><a href="http://api.jquery.com/category/events/">See the various events supported by jQuery.</a></td>
<td class="not-for-mobile">
<form parsley-validate>
<p><input type="text" parsley-type="email" parsley-trigger="keyup" parsley-validation-minlength="0" placeholder="keyup validation trigger" /><p>
<p><input type="text" parsley-type="email" parsley-trigger="change" parsley-validation-minlength="0" placeholder="change validation trigger" /></p>
<input type="checkbox" name="mincheckdemo[]" parsley-mincheck="2" value="foo" parsley-trigger="change" />
<input type="checkbox" name="mincheckdemo[]" value="bar" />
<input type="checkbox" name="mincheckdemo[]" value="baz" />
</form>
</td>
</tr>
<tr>
<td>
<code>parsley-value</code>
</td>
<td>
</td>
<td>
Override the value attribute of a form field. Useful for file inputs, where you're not allowed to
set a value. <br/>
eg: <code>parsley-value="uploadedfile.png"</code>
</td>
<td class="not-for-mobile">
</td>
</tr>
<tr>
<td>
<code>parsley-validation-minlength</code>
</td>
<td>
3
</td>
<td>
Specify how many characters need to be input before the the validation process fires.<br/>
eg: <code>parsley-validation-minlength="4"</code>
</td>
<td class="not-for-mobile">
<form parsley-validate>
<p><input type="text" parsley-type="email" parsley-trigger="keyup" placeholder="default keyup validation" /><p>
<p><input type="text" parsley-type="email" parsley-trigger="keyup" parsley-validation-minlength="8" placeholder="8 chars keyup validation" /></p>
</form>
</td>
</tr>
<tr>
<td>
<code>parsley-error-message</code>
</td>
<td>
</td>
<td>
Customize a unique global message for this field. Shown if one constraint fails.
<br/>eg: <pre><code>parsley-type="alphanum" parsley-rangelength="[10,10]"
parsley-error-message="You must enter a 10 characters alphanumeric value"</code></pre>
</td>
<td class="not-for-mobile">
<form parsley-validate>
<p><input type="text" parsley-type="alphanum" parsley-rangelength="[10,10]" parsley-trigger="keyup" parsley-error-message="You must enter a 10 characters alphanumeric value" placeholder="custom error message" /><p>
</form>
</td>
</tr>
<tr>
<td>
<code>parsley-error-container</code>
</td>
<td>
</td>
<td>
<span style="color:red; !important" id="demoerrorcontainer"></span>
Specify here the container where Parsley should set the errors.
<br/>eg: <pre><code>parsley-error-container="ul#myproperlabel li.someclass"</code></pre>
</td>
<td class="not-for-mobile">
<form parsley-validate>
<p><input type="text" parsley-type="email" parsley-trigger="keyup" parsley-validation-minlength="0" parsley-error-container="#demoerrorcontainer" placeholder="error will pop above text on the left" /><p>
</form>
</td>
</tr>
<tr>
<td>
<code>parsley-`constraintName`-message</code><br/><br/>
<code>parsley-type-`type`-message</code>
</td>
<td>
</td>
<td>
Customize the error message for the field constraint.<br/>
eg: <code>parsley-minlength-message="Custom minlength message"</code><br/><br/>
<code>parsley-type-email-message="Custom email message"</code>
</td>
<td class="not-for-mobile">
<form parsley-validate>
<p><input type="text" parsley-type="email" parsley-minlength="20" parsley-trigger="keyup" parsley-type-email-message="Custom email message" parsley-minlength-message="Custom minlength message" placeholder="custom error messages" /><p>
</form>
</td>
</tr>
</tbody>
</table>
</section>
<a href="#top" class="top pull-right">Top</a>
<!-- //////////////////////////////////////////////////////////////////////////////////////////////////// -->
<section>
<a name="validators"></a>
<div class="page-header">
<h3>Built-in Validators</h3>
</div>
<table class="table table-striped table-bordered table-hover">
<thead>
<tr>
<th>Name</th>
<th>API</th>
<th>Description</th>
<th class="not-for-mobile">Demonstration</th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="4">
<a name="basic-constraints"></a>
<h4>Basic constraints</h4>
</td>
</tr>
<!-- Required -->
<tr>
<td>Required</td>
<td>
<code>parsley-required="true"</code><br/><br/>
<code>class="required"</code><br/><br/>
<span class="label label-info">HTML5</span><code>required</code><br/>
<span class="label label-info">HTML5</span><code>required="required"</code>
</td>
<td>Validate that a required field has been filled.</td>
<td class="not-for-mobile">
<table>
<tr>
<td>
<form parsley-validate id="form-required">
<input type="text" id="parsley-required" parsley-required="true" placeholder="required field" /><br/><br/>
<select id="select-required" parsley-required="true">
<option value="">Please choose</option>
<option value="foo">Foo</option>
<option value="bar">Bar</option>
</select><br/>
Radio: <input type="radio" name="radiorequired" value="foo" id="radio-required" parsley-required="true"/>
<input type="radio" name="radiorequired" id="radio-required2" value="bar" />
</form>
</td>
<td>
<span class="btn btn-small" onclick="javascript:$('#form-required').parsley('validate');">
<i class="icon-ok"></i>
</span>
</td>
</tr>
</table>
</td>
</tr>
<!-- Notblank -->
<tr>
<td>Not Blank</td>
<td>
<code>parsley-notblank="true"</code>
</td>
<td>Validates that a value is not blank, defined as not equal to a blank string.</td>
<td class="not-for-mobile">
<table>
<tr>
<td>
<form parsley-validate>
<input type="text" id="parsley-notblank" parsley-notblank="true" placeholder="not blank field" />
</form>
</td>
<td>
<span class="btn btn-small" onclick="javascript:$('#parsley-notblank').parsley('validate');">
<i class="icon-ok"></i>
</span>
</td>
</tr>
</table>
</td>
</tr>
<!-- Minlength -->
<tr>
<td>Min Length</td>
<td>
<code>parsley-minlength="6"</code>
</td>
<td>Validates that the length of a string is at least as long as the given limit.</td>
<td class="not-for-mobile">
<table>
<tr>
<td>
<form parsley-validate>
<input type="text" id="parsley-minlength" parsley-minlength="6" placeholder="minlength = 6" />
</form>
</td>
<td>
<span class="btn btn-small" onclick="javascript:$('#parsley-minlength').parsley('validate');">
<i class="icon-ok"></i>
</span>
</td>
</tr>
</table>
</td>
</tr>
<!-- MaxLength -->
<tr>
<td>Max Length</td>
<td>
<code>parsley-maxlength="6"</code>
</td>
<td>Validates that the length of a string is not larger than the given limit.</td>
<td class="not-for-mobile">
<table>
<tr>
<td>
<form parsley-validate>
<input type="text" id="parsley-maxlength" parsley-maxlength="6" placeholder="maxlength = 6" />
</form>
</td>
<td>
<span class="btn btn-small" onclick="javascript:$('#parsley-maxlength').parsley('validate');">
<i class="icon-ok"></i>
</span>
</td>
</tr>
</table>
</td>
</tr>
<!-- RangeLength -->
<tr>
<td>Range Length</td>
<td>
<code>parsley-rangelength="[5,10]"</code>
</td>
<td>Validates that a given string length is between some minimum and maximum value.</td>
<td class="not-for-mobile">
<table>
<tr>
<td>
<form parsley-validate>
<input type="text" id="parsley-rangelength" parsley-rangelength="[5,10]" placeholder="rangelength = [5,10]" />
</form>
</td>
<td>
<span class="btn btn-small" onclick="javascript:$('#parsley-rangelength').parsley('validate');">
<i class="icon-ok"></i>
</span>
</td>
</tr>
</table>
</td>
</tr>
<!-- Min -->
<tr>
<td>Min</td>
<td>
<code>parsley-min="6"</code><br/><br/>
<span class="label label-info">HTML5</span><code>type="number" min="6"</code>
</td>
<td>Validates that a given number is greater than some minimum number.</td>
<td class="not-for-mobile">
<table>
<tr>
<td>
<form parsley-validate>
<input type="text" id="parsley-minimum" parsley-min="6" placeholder="min = 6" />
</form>
</td>
<td>
<span class="btn btn-small" onclick="javascript:$('#parsley-minimum').parsley('validate');">
<i class="icon-ok"></i>
</span>
</td>
</tr>
</table>
</td>
</tr>
<!-- Max -->
<tr>
<td>Max</td>
<td>
<code>parsley-max="100"</code><br/><br/>
<span class="label label-info">HTML5</span><code>type="number" max="100"</code>
</td>
<td>Validates that a given number is less than some maximum number.</td>
<td class="not-for-mobile">
<table>
<tr>
<td>
<form parsley-validate>
<input type="text" id="parsley-maximum" parsley-max="100" placeholder="max = 100" />
</form>
</td>
<td>
<span class="btn btn-small" onclick="javascript:$('#parsley-maximum').parsley('validate');">
<i class="icon-ok"></i>
</span>
</td>
</tr>
</table>
</td>
</tr>
<!-- Range -->
<tr>
<td>Range</td>
<td>
<code>parsley-range="[6, 100]"</code><br/><br/>
<span class="label label-info">HTML5</span><code>type="range" min="6" max="100"</code>
</td>
<td>Validates that a given number is between some minimum and maximum number.</td>
<td class="not-for-mobile">
<table>
<tr>
<td>
<form parsley-validate>
<input type="text" id="parsley-range" parsley-range="[6, 100]" placeholder="range = [6,100]" />
</form>
</td>
<td>
<span class="btn btn-small" onclick="javascript:$('#parsley-range').parsley('validate');">
<i class="icon-ok"></i>
</span>
</td>
</tr>
</table>
</td>
</tr>
<!-- RegExp -->
<tr>
<td>RegExp</td>
<td>
<code>parsley-regexp="<regexp>"</code><br/><br/>
<span class="label label-info">HTML5</span><code>pattern="regexp"</code>
</td>
<td>Validates that a value matches a specific regular expression. eg: validate a color hexadecimal code: <code>parsley-regexp="#[A-Fa-f0-9]{6}"</code>.<br/><br/>Add a flag to <code>Regexp()</code> function: <code>parsley-regexp-flag="i"</code> for example to make regexp case unsensitive</td>
<td class="not-for-mobile">
<table>
<tr>
<td>
<form parsley-validate>
<input type="text" id="parsley-regexp" parsley-regexp="#[A-Fa-f0-9]{6}" placeholder="hexa color code" />
</form>
</td>
<td>
<span class="btn btn-small" onclick="javascript:$('#parsley-regexp').parsley('validate');">
<i class="icon-ok"></i>
</span>
</td>
</tr>
</table>
</td>
</tr>
<!-- EqualTo -->
<tr>
<td>Equal To</td>
<td>
<code>parsley-equalto="#elem"</code>
</td>
<td>Validates that a value is identical to #elem value. Useful for password repeat validation.</td>
<td class="not-for-mobile">
<table>
<tr>
<td>
<form parsley-validate>
<input type="text" id="eqalToModel" parsley-equalTo="#eqalToModel" value="foo" />
<input type="text" id="parsley-equalto" parsley-equalTo="#eqalToModel" placeholder="equal to foo" />
</form>
</td>
<td>
<span class="btn btn-small" onclick="javascript:$('#parsley-equalto').parsley('validate');">
<i class="icon-ok"></i>
</span>
</td>
</tr>
</table>
</td>
</tr>
<!-- minChecked -->
<tr>
<td>Min check</td>
<td>
<code>parsley-mincheck="2"</code>
</td>
<td>Validates that a certain minimum number of checkboxes in a group are checked. You can define a group by giving the same name to radio / checkboxes elements or add a <code>parsley-group="mygroup"</code> property to each one of them</td>
<td class="not-for-mobile">
<table>
<tr>
<td>
<small>Check at least 2 checkboxes:</small>
<form parsley-validate>
<input type="checkbox" id="mincheck" name="mincheck[]" parsley-mincheck="2" value="foo" />
<input type="checkbox" name="mincheck[]" value="bar" />
<input type="checkbox" name="mincheck[]" value="baz" />
</form>
</td>
<td>
<span class="btn btn-small" onclick="javascript:$('#mincheck').parsley( 'validate' );">
<i class="icon-ok"></i>
</span>
</td>
</tr>
</table>
</td>
</tr>
<!-- maxChecked -->
<tr>
<td>Max check</td>
<td>
<code>parsley-maxcheck="2"</code>
</td>
<td>Validates that a certain maximum number of checkboxes in a group are checked. You can define a group by giving the same name to radio / checkboxes elements or add a <code>parsley-group="mygroup"</code> property to each one of them</td>
<td class="not-for-mobile">
<table>
<tr>
<td>
<small>Check 2 checkboxes maximum:</small>
<form parsley-validate>
<input type="checkbox" id="maxcheck" name="maxcheck[]" parsley-maxcheck="2" value="foo" />
<input type="checkbox" name="maxcheck[]" value="bar" />
<input type="checkbox" name="maxcheck[]" value="baz" />
</form>
</td>
<td>
<span class="btn btn-small" onclick="javascript:$('#maxcheck').parsley( 'validate' );">
<i class="icon-ok"></i>
</span>
</td>
</tr>
</table>
</td>
</tr>
<!-- rangeChecked -->
<tr>
<td>Range check</td>
<td>
<code>parsley-rangecheck="[1,2]"</code>
</td>
<td>Validates that the number of checked checkboxes in a group is with a certain range. You can define a group by giving the same name to radio / checkboxes elements or add a <code>parsley-group="mygroup"</code> property to each one of them</td>
<td class="not-for-mobile">
<table>
<tr>
<td>
<small>Check b/w 1&2 checkboxes:</small>
<form parsley-validate>
<span>
<input type="checkbox" id="rangecheck" name="rangecheck[]" parsley-rangecheck="[1,2]" value="foo" />
<input type="checkbox" name="rangecheck[]" value="bar" />
<input type="checkbox" name="rangecheck[]" value="baz" />
</span>
</form>
</td>
<td>
<span class="btn btn-small" onclick="javascript:$('#rangecheck').parsley( 'validate' );">
<i class="icon-ok"></i>
</span>
</td>
</tr>
</table>
</td>
</tr>
<!-- Remote -->
<tr>
<td>Remote (Ajax)</td>
<td>
<code>parsley-remote="http://yoururl.com"</code>
</td>
<td colspan="2"><strong>Custom ajax validation made simple.</strong><br/>
<code>parsley-remote-method="POST"</code> to change default <code>GET</code> call.<br/>
<code>parsley-remote-datatype="jsonp"</code> if you make cross domain ajax call and expect <code>jsonp</code><br/>
Parsley will accept these valid returns with a 200 response code: <code>1</code>, <code>true</code>, <code>{ "success": "..." }</code> and assume false otherwise<br/>
You can show frontend server-side specific error messages by returning <code>{ "error": "your custom message" }</code> or <code>{ "message": "your custom message" }</code>
</td>
</tr>
<tr>
<td colspan="4">
<a name="type-constraints"></a>
<h4>Type Constraints</h4>
</td>
</tr>
<!-- Email -->
<tr>
<td>Email</td>
<td>
<code>parsley-type="email"</code><br/><br/>
<span class="label label-info">HTML5</span><code>type="email"</code>
</td>
<td>Validates that a value is a valid email address.</td>
<td class="not-for-mobile">
<table>
<tr>
<td>
<form parsley-validate>
<input type="text" id="parsley-email" parsley-type="email" placeholder="email" />
</form>
</td>
<td>
<span class="btn btn-small" onclick="javascript:$('#parsley-email').parsley('validate');">
<i class="icon-ok"></i>
</span>
</td>
</tr>
</table>
</td>
</tr>
<!-- Url -->
<tr>
<td>Url</td>
<td>
<code>parsley-type="url"</code>
<code>type="url"</code>
</td>
<td>Validates that a value is a valid url.</td>
<td class="not-for-mobile">
<table>
<tr>
<td>
<form parsley-validate>
<input type="text" id="parsley-url" parsley-type="url" placeholder="url" />
</form>
</td>
<td>
<span class="btn btn-small" onclick="javascript:$('#parsley-url').parsley('validate');">
<i class="icon-ok"></i>
</span>
</td>
</tr>
</table>
</td>
</tr>
<!-- Url Strict -->
<tr>
<td>Url strict</td>
<td>
<code>parsley-type="urlstrict"</code>
</td>
<td>Validates that a value is a valid strict URL, ie: with one of <code>http</code>, <code>https</code>, <code>ftp</code>, <code>git</code> allowed protocols.</td>
<td class="not-for-mobile">
<table>
<tr>
<td>
<form parsley-validate>
<input type="text" id="parsley-url-strict" parsley-type="urlstrict" placeholder="urlstrict" />
</form>
</td>
<td>
<span class="btn btn-small" onclick="javascript:$('#parsley-url-strict').parsley('validate');">
<i class="icon-ok"></i>
</span>
</td>
</tr>
</table>
</td>
</tr>
<!-- Digits -->
<tr>
<td>Digits</td>
<td>
<code>parsley-type="digits"</code>
</td>
<td>Validates that a value is only digits.</td>
<td class="not-for-mobile">
<table>
<tr>
<td>
<form parsley-validate>
<input type="text" id="parsley-digits" parsley-type="digits" placeholder="digits" />
</form>
</td>
<td>
<span class="btn btn-small" onclick="javascript:$('#parsley-digits').parsley('validate');">
<i class="icon-ok"></i>
</span>
</td>
</tr>
</table>
</td>
</tr>
<!-- Number -->
<tr>
<td>Number</td>
<td>
<code>parsley-type="number"</code><br/><br/>
<span class="label label-info">HTML5</span><code>type="number"</code>
</td>
<td>Validates that a value is a valid number.</td>
<td class="not-for-mobile">
<table>
<tr>
<td>
<form parsley-validate>
<input type="text" id="parsley-number" parsley-type="number" placeholder="number" />
</form>
</td>
<td>
<span class="btn btn-small" onclick="javascript:$('#parsley-number').parsley('validate');">
<i class="icon-ok"></i>
</span>
</td>
</tr>
</table>
</td>
</tr>
<!-- Alphanum -->
<tr>
<td>Alphanum</td>
<td>