1
1
/*!
2
2
* jQuery Validation Plugin 1.12.0pre
3
3
*
4
- * http://bassistance.de/jquery-plugins/jquery-plugin-validation/
5
- * http://docs.jquery.com/Plugins/Validation
4
+ * http://jqueryvalidation.org//
6
5
*
7
6
* Copyright 2013 Jörn Zaefferer
8
7
* Released under the MIT license:
12
11
( function ( $ ) {
13
12
14
13
$ . extend ( $ . fn , {
15
- // http://docs.jquery.com/Plugins/Validation/ validate
14
+ // http://jqueryvalidation.org/ validate/
16
15
validate :function ( options ) {
17
16
18
17
// if nothing is selected, return nothing; can't chain anyway
@@ -95,7 +94,7 @@ $.extend($.fn, {
95
94
96
95
return validator ;
97
96
} ,
98
- // http://docs.jquery.com/Plugins/Validation/ valid
97
+ // http://jqueryvalidation.org/ valid/
99
98
valid :function ( ) {
100
99
if ( $ ( this [ 0 ] ) . is ( "form" ) ) {
101
100
return this . validate ( ) . form ( ) ;
@@ -118,7 +117,7 @@ $.extend($.fn, {
118
117
} ) ;
119
118
return result ;
120
119
} ,
121
- // http://docs.jquery.com/Plugins/Validation/ rules
120
+ // http://jqueryvalidation.org/ rules/
122
121
rules :function ( command , argument ) {
123
122
var element = this [ 0 ] ;
124
123
@@ -172,11 +171,11 @@ $.extend($.fn, {
172
171
173
172
// Custom selectors
174
173
$ . extend ( $ . expr [ ":" ] , {
175
- // http://docs.jquery.com/Plugins/Validation/ blank
174
+ // http://jqueryvalidation.org/ blank-selector/
176
175
blank :function ( a ) { return ! $ . trim ( "" + $ ( a ) . val ( ) ) ; } ,
177
- // http://docs.jquery.com/Plugins/Validation/ filled
176
+ // http://jqueryvalidation.org/ filled-selector/
178
177
filled :function ( a ) { return ! ! $ . trim ( "" + $ ( a ) . val ( ) ) ; } ,
179
- // http://docs.jquery.com/Plugins/Validation/ unchecked
178
+ // http://jqueryvalidation.org/ unchecked-selector/
180
179
unchecked :function ( a ) { return ! $ ( a ) . prop ( "checked" ) ; }
181
180
} ) ;
182
181
@@ -187,6 +186,7 @@ $.validator = function( options, form ) {
187
186
this . init ( ) ;
188
187
} ;
189
188
189
+ // http://jqueryvalidation.org/jQuery.validator.format/
190
190
$ . validator . format = function ( source , params ) {
191
191
if ( arguments . length === 1 ) {
192
192
return function ( ) {
@@ -273,7 +273,7 @@ $.extend($.validator, {
273
273
}
274
274
} ,
275
275
276
- // http://docs.jquery.com/Plugins/Validation/Validator/ setDefaults
276
+ // http://jqueryvalidation.org/jQuery.validator. setDefaults/
277
277
setDefaults :function ( settings ) {
278
278
$ . extend ( $ . validator . defaults , settings ) ;
279
279
} ,
@@ -347,7 +347,7 @@ $.extend($.validator, {
347
347
}
348
348
} ,
349
349
350
- // http://docs.jquery.com/Plugins/Validation/ Validator/ form
350
+ // http://jqueryvalidation.org/ Validator. form/
351
351
form :function ( ) {
352
352
this . checkForm ( ) ;
353
353
$ . extend ( this . submitted , this . errorMap ) ;
@@ -367,7 +367,7 @@ $.extend($.validator, {
367
367
return this . valid ( ) ;
368
368
} ,
369
369
370
- // http://docs.jquery.com/Plugins/Validation/ Validator/ element
370
+ // http://jqueryvalidation.org/ Validator. element/
371
371
element :function ( element ) {
372
372
element = this . validationTargetFor ( this . clean ( element ) ) ;
373
373
this . lastElement = element ;
@@ -387,7 +387,7 @@ $.extend($.validator, {
387
387
return result ;
388
388
} ,
389
389
390
- // http://docs.jquery.com/Plugins/Validation/ Validator/ showErrors
390
+ // http://jqueryvalidation.org/ Validator. showErrors/
391
391
showErrors :function ( errors ) {
392
392
if ( errors ) {
393
393
// add items to error list and map
@@ -411,7 +411,7 @@ $.extend($.validator, {
411
411
}
412
412
} ,
413
413
414
- // http://docs.jquery.com/Plugins/Validation/ Validator/ resetForm
414
+ // http://jqueryvalidation.org/ Validator. resetForm/
415
415
resetForm :function ( ) {
416
416
if ( $ . fn . resetForm ) {
417
417
$ ( this . currentForm ) . resetForm ( ) ;
@@ -981,7 +981,7 @@ $.extend($.validator, {
981
981
return data ;
982
982
} ,
983
983
984
- // http://docs.jquery.com/Plugins/Validation/Validator/ addMethod
984
+ // http://jqueryvalidation.org/jQuery.validator. addMethod/
985
985
addMethod :function ( name , method , message ) {
986
986
$ . validator . methods [ name ] = method ;
987
987
$ . validator . messages [ name ] = message !== undefined ?message :$ . validator . messages [ name ] ;
@@ -992,7 +992,7 @@ $.extend($.validator, {
992
992
993
993
methods :{
994
994
995
- // http://docs.jquery.com/Plugins/Validation/Methods/ required
995
+ // http://jqueryvalidation.org/ required-method/
996
996
required :function ( value , element , param ) {
997
997
// check if dependency is met
998
998
if ( ! this . depend ( param , element ) ) {
@@ -1009,40 +1009,40 @@ $.extend($.validator, {
1009
1009
return $ . trim ( value ) . length > 0 ;
1010
1010
} ,
1011
1011
1012
- // http://docs.jquery.com/Plugins/Validation/Methods/ email
1012
+ // http://jqueryvalidation.org/ email-method/
1013
1013
email :function ( value , element ) {
1014
1014
// contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/
1015
1015
return this . optional ( element ) || / ^ ( ( ( [ a - z ] | \d | [ ! # \$ % & ' \* \+ \- \/ = \? \^ _ ` { \| } ~ ] | [ \u00A0 - \uD7FF \uF900 - \uFDCF \uFDF0 - \uFFEF ] ) + ( \. ( [ a - z ] | \d | [ ! # \$ % & ' \* \+ \- \/ = \? \^ _ ` { \| } ~ ] | [ \u00A0 - \uD7FF \uF900 - \uFDCF \uFDF0 - \uFFEF ] ) + ) * ) | ( ( \x22 ) ( ( ( ( \x20 | \x09 ) * ( \x0d \x0a ) ) ? ( \x20 | \x09 ) + ) ? ( ( [ \x01 - \x08 \x0b \x0c \x0e - \x1f \x7f ] | \x21 | [ \x23 - \x5b ] | [ \x5d - \x7e ] | [ \u00A0 - \uD7FF \uF900 - \uFDCF \uFDF0 - \uFFEF ] ) | ( \\ ( [ \x01 - \x09 \x0b \x0c \x0d - \x7f ] | [ \u00A0 - \uD7FF \uF900 - \uFDCF \uFDF0 - \uFFEF ] ) ) ) ) * ( ( ( \x20 | \x09 ) * ( \x0d \x0a ) ) ? ( \x20 | \x09 ) + ) ? ( \x22 ) ) ) @ ( ( ( [ a - z ] | \d | [ \u00A0 - \uD7FF \uF900 - \uFDCF \uFDF0 - \uFFEF ] ) | ( ( [ a - z ] | \d | [ \u00A0 - \uD7FF \uF900 - \uFDCF \uFDF0 - \uFFEF ] ) ( [ a - z ] | \d | - | \. | _ | ~ | [ \u00A0 - \uD7FF \uF900 - \uFDCF \uFDF0 - \uFFEF ] ) * ( [ a - z ] | \d | [ \u00A0 - \uD7FF \uF900 - \uFDCF \uFDF0 - \uFFEF ] ) ) ) \. ) + ( ( [ a - z ] | [ \u00A0 - \uD7FF \uF900 - \uFDCF \uFDF0 - \uFFEF ] ) | ( ( [ a - z ] | [ \u00A0 - \uD7FF \uF900 - \uFDCF \uFDF0 - \uFFEF ] ) ( [ a - z ] | \d | - | \. | _ | ~ | [ \u00A0 - \uD7FF \uF900 - \uFDCF \uFDF0 - \uFFEF ] ) * ( [ a - z ] | [ \u00A0 - \uD7FF \uF900 - \uFDCF \uFDF0 - \uFFEF ] ) ) ) $ / i. test ( value ) ;
1016
1016
} ,
1017
1017
1018
- // http://docs.jquery.com/Plugins/Validation/Methods/ url
1018
+ // http://jqueryvalidation.org/ url-method/
1019
1019
url :function ( value , element ) {
1020
1020
// contributed by Scott Gonzalez: http://projects.scottsplayground.com/iri/
1021
1021
return this . optional ( element ) || / ^ ( h t t p s ? | s ? f t p ) : \/ \/ ( ( ( ( [ a - z ] | \d | - | \. | _ | ~ | [ \u00A0 - \uD7FF \uF900 - \uFDCF \uFDF0 - \uFFEF ] ) | ( % [ \d a - f ] { 2 } ) | [ ! \$ & ' \( \) \* \+ , ; = ] | : ) * @ ) ? ( ( ( \d | [ 1 - 9 ] \d | 1 \d \d | 2 [ 0 - 4 ] \d | 2 5 [ 0 - 5 ] ) \. ( \d | [ 1 - 9 ] \d | 1 \d \d | 2 [ 0 - 4 ] \d | 2 5 [ 0 - 5 ] ) \. ( \d | [ 1 - 9 ] \d | 1 \d \d | 2 [ 0 - 4 ] \d | 2 5 [ 0 - 5 ] ) \. ( \d | [ 1 - 9 ] \d | 1 \d \d | 2 [ 0 - 4 ] \d | 2 5 [ 0 - 5 ] ) ) | ( ( ( [ a - z ] | \d | [ \u00A0 - \uD7FF \uF900 - \uFDCF \uFDF0 - \uFFEF ] ) | ( ( [ a - z ] | \d | [ \u00A0 - \uD7FF \uF900 - \uFDCF \uFDF0 - \uFFEF ] ) ( [ a - z ] | \d | - | \. | _ | ~ | [ \u00A0 - \uD7FF \uF900 - \uFDCF \uFDF0 - \uFFEF ] ) * ( [ a - z ] | \d | [ \u00A0 - \uD7FF \uF900 - \uFDCF \uFDF0 - \uFFEF ] ) ) ) \. ) + ( ( [ a - z ] | [ \u00A0 - \uD7FF \uF900 - \uFDCF \uFDF0 - \uFFEF ] ) | ( ( [ a - z ] | [ \u00A0 - \uD7FF \uF900 - \uFDCF \uFDF0 - \uFFEF ] ) ( [ a - z ] | \d | - | \. | _ | ~ | [ \u00A0 - \uD7FF \uF900 - \uFDCF \uFDF0 - \uFFEF ] ) * ( [ a - z ] | [ \u00A0 - \uD7FF \uF900 - \uFDCF \uFDF0 - \uFFEF ] ) ) ) \. ? ) ( : \d * ) ? ) ( \/ ( ( ( [ a - z ] | \d | - | \. | _ | ~ | [ \u00A0 - \uD7FF \uF900 - \uFDCF \uFDF0 - \uFFEF ] ) | ( % [ \d a - f ] { 2 } ) | [ ! \$ & ' \( \) \* \+ , ; = ] | : | @ ) + ( \/ ( ( [ a - z ] | \d | - | \. | _ | ~ | [ \u00A0 - \uD7FF \uF900 - \uFDCF \uFDF0 - \uFFEF ] ) | ( % [ \d a - f ] { 2 } ) | [ ! \$ & ' \( \) \* \+ , ; = ] | : | @ ) * ) * ) ? ) ? ( \? ( ( ( [ a - z ] | \d | - | \. | _ | ~ | [ \u00A0 - \uD7FF \uF900 - \uFDCF \uFDF0 - \uFFEF ] ) | ( % [ \d a - f ] { 2 } ) | [ ! \$ & ' \( \) \* \+ , ; = ] | : | @ ) | [ \uE000 - \uF8FF ] | \/ | \? ) * ) ? ( # ( ( ( [ a - z ] | \d | - | \. | _ | ~ | [ \u00A0 - \uD7FF \uF900 - \uFDCF \uFDF0 - \uFFEF ] ) | ( % [ \d a - f ] { 2 } ) | [ ! \$ & ' \( \) \* \+ , ; = ] | : | @ ) | \/ | \? ) * ) ? $ / i. test ( value ) ;
1022
1022
} ,
1023
1023
1024
- // http://docs.jquery.com/Plugins/Validation/Methods/ date
1024
+ // http://jqueryvalidation.org/ date-method/
1025
1025
date :function ( value , element ) {
1026
1026
return this . optional ( element ) || ! / I n v a l i d | N a N / . test ( new Date ( value ) . toString ( ) ) ;
1027
1027
} ,
1028
1028
1029
- // http://docs.jquery.com/Plugins/Validation/Methods/ dateISO
1029
+ // http://jqueryvalidation.org/ dateISO-method/
1030
1030
dateISO :function ( value , element ) {
1031
1031
return this . optional ( element ) || / ^ \d { 4 } [ \/ \- ] \d { 1 , 2 } [ \/ \- ] \d { 1 , 2 } $ / . test ( value ) ;
1032
1032
} ,
1033
1033
1034
- // http://docs.jquery.com/Plugins/Validation/Methods/ number
1034
+ // http://jqueryvalidation.org/ number-method/
1035
1035
number :function ( value , element ) {
1036
1036
return this . optional ( element ) || / ^ - ? (?: \d + | \d { 1 , 3 } (?: , \d { 3 } ) + ) ? (?: \. \d + ) ? $ / . test ( value ) ;
1037
1037
} ,
1038
1038
1039
- // http://docs.jquery.com/Plugins/Validation/Methods/ digits
1039
+ // http://jqueryvalidation.org/ digits-method/
1040
1040
digits :function ( value , element ) {
1041
1041
return this . optional ( element ) || / ^ \d + $ / . test ( value ) ;
1042
1042
} ,
1043
1043
1044
- // http://docs.jquery.com/Plugins/Validation/Methods/ creditcard
1045
- // based on http://en.wikipedia.org/wiki/Luhn
1044
+ // http://jqueryvalidation.org/ creditcard-method/
1045
+ // based on http://en.wikipedia.org/wiki/Luhn/
1046
1046
creditcard :function ( value , element ) {
1047
1047
if ( this . optional ( element ) ) {
1048
1048
return "dependency-mismatch" ;
@@ -1072,40 +1072,40 @@ $.extend($.validator, {
1072
1072
return ( nCheck % 10 ) === 0 ;
1073
1073
} ,
1074
1074
1075
- // http://docs.jquery.com/Plugins/Validation/Methods/ minlength
1075
+ // http://jqueryvalidation.org/ minlength-method/
1076
1076
minlength :function ( value , element , param ) {
1077
1077
var length = $ . isArray ( value ) ?value . length :this . getLength ( $ . trim ( value ) , element ) ;
1078
1078
return this . optional ( element ) || length >= param ;
1079
1079
} ,
1080
1080
1081
- // http://docs.jquery.com/Plugins/Validation/Methods/ maxlength
1081
+ // http://jqueryvalidation.org/ maxlength-method/
1082
1082
maxlength :function ( value , element , param ) {
1083
1083
var length = $ . isArray ( value ) ?value . length :this . getLength ( $ . trim ( value ) , element ) ;
1084
1084
return this . optional ( element ) || length <= param ;
1085
1085
} ,
1086
1086
1087
- // http://docs.jquery.com/Plugins/Validation/Methods/ rangelength
1087
+ // http://jqueryvalidation.org/ rangelength-method/
1088
1088
rangelength :function ( value , element , param ) {
1089
1089
var length = $ . isArray ( value ) ?value . length :this . getLength ( $ . trim ( value ) , element ) ;
1090
1090
return this . optional ( element ) || ( length >= param [ 0 ] && length <= param [ 1 ] ) ;
1091
1091
} ,
1092
1092
1093
- // http://docs.jquery.com/Plugins/Validation/Methods/ min
1093
+ // http://jqueryvalidation.org/ min-method/
1094
1094
min :function ( value , element , param ) {
1095
1095
return this . optional ( element ) || value >= param ;
1096
1096
} ,
1097
1097
1098
- // http://docs.jquery.com/Plugins/Validation/Methods/ max
1098
+ // http://jqueryvalidation.org/ max-method/
1099
1099
max :function ( value , element , param ) {
1100
1100
return this . optional ( element ) || value <= param ;
1101
1101
} ,
1102
1102
1103
- // http://docs.jquery.com/Plugins/Validation/Methods/ range
1103
+ // http://jqueryvalidation.org/ range-method/
1104
1104
range :function ( value , element , param ) {
1105
1105
return this . optional ( element ) || ( value >= param [ 0 ] && value <= param [ 1 ] ) ;
1106
1106
} ,
1107
1107
1108
- // http://docs.jquery.com/Plugins/Validation/Methods/ equalTo
1108
+ // http://jqueryvalidation.org/ equalTo-method/
1109
1109
equalTo :function ( value , element , param ) {
1110
1110
// bind to the blur event of the target in order to revalidate whenever the target field is updated
1111
1111
// TODO find a way to bind the event just once, avoiding the unbind-rebind overhead
@@ -1118,7 +1118,7 @@ $.extend($.validator, {
1118
1118
return value === target . val ( ) ;
1119
1119
} ,
1120
1120
1121
- // http://docs.jquery.com/Plugins/Validation/Methods/ remote
1121
+ // http://jqueryvalidation.org/ remote-method/
1122
1122
remote :function ( value , element , param ) {
1123
1123
if ( this . optional ( element ) ) {
1124
1124
return "dependency-mismatch" ;