jquery-validation-rails 1.12.0 → 1.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/app/assets/javascripts/jquery.validate.additional-methods.js +181 -74
- data/app/assets/javascripts/jquery.validate.js +407 -335
- data/app/assets/javascripts/jquery.validate.localization/messages_ar.js +29 -21
- data/app/assets/javascripts/jquery.validate.localization/messages_bg.js +29 -21
- data/app/assets/javascripts/jquery.validate.localization/messages_ca.js +29 -21
- data/app/assets/javascripts/jquery.validate.localization/messages_cs.js +29 -21
- data/app/assets/javascripts/jquery.validate.localization/messages_da.js +26 -18
- data/app/assets/javascripts/jquery.validate.localization/messages_de.js +26 -18
- data/app/assets/javascripts/jquery.validate.localization/messages_el.js +29 -21
- data/app/assets/javascripts/jquery.validate.localization/messages_es.js +32 -24
- data/app/assets/javascripts/jquery.validate.localization/messages_es_AR.js +32 -24
- data/app/assets/javascripts/jquery.validate.localization/messages_et.js +27 -19
- data/app/assets/javascripts/jquery.validate.localization/messages_eu.js +29 -21
- data/app/assets/javascripts/jquery.validate.localization/messages_fa.js +32 -21
- data/app/assets/javascripts/jquery.validate.localization/messages_fi.js +27 -19
- data/app/assets/javascripts/jquery.validate.localization/messages_fr.js +55 -46
- data/app/assets/javascripts/jquery.validate.localization/messages_gl.js +38 -0
- data/app/assets/javascripts/jquery.validate.localization/messages_he.js +29 -21
- data/app/assets/javascripts/jquery.validate.localization/messages_hr.js +29 -21
- data/app/assets/javascripts/jquery.validate.localization/messages_hu.js +28 -20
- data/app/assets/javascripts/jquery.validate.localization/messages_id.js +28 -20
- data/app/assets/javascripts/jquery.validate.localization/messages_is.js +27 -19
- data/app/assets/javascripts/jquery.validate.localization/messages_it.js +32 -24
- data/app/assets/javascripts/jquery.validate.localization/messages_ja.js +29 -21
- data/app/assets/javascripts/jquery.validate.localization/messages_ka.js +29 -21
- data/app/assets/javascripts/jquery.validate.localization/messages_kk.js +29 -21
- data/app/assets/javascripts/jquery.validate.localization/messages_ko.js +29 -21
- data/app/assets/javascripts/jquery.validate.localization/messages_lt.js +29 -21
- data/app/assets/javascripts/jquery.validate.localization/messages_lv.js +29 -21
- data/app/assets/javascripts/jquery.validate.localization/messages_my.js +29 -21
- data/app/assets/javascripts/jquery.validate.localization/messages_nl.js +38 -30
- data/app/assets/javascripts/jquery.validate.localization/messages_no.js +29 -21
- data/app/assets/javascripts/jquery.validate.localization/messages_pl.js +29 -21
- data/app/assets/javascripts/jquery.validate.localization/messages_pt_BR.js +33 -24
- data/app/assets/javascripts/jquery.validate.localization/messages_pt_PT.js +32 -24
- data/app/assets/javascripts/jquery.validate.localization/messages_ro.js +29 -21
- data/app/assets/javascripts/jquery.validate.localization/messages_ru.js +29 -21
- data/app/assets/javascripts/jquery.validate.localization/messages_si.js +29 -21
- data/app/assets/javascripts/jquery.validate.localization/messages_sk.js +26 -18
- data/app/assets/javascripts/jquery.validate.localization/messages_sl.js +29 -21
- data/app/assets/javascripts/jquery.validate.localization/messages_sr.js +29 -21
- data/app/assets/javascripts/jquery.validate.localization/messages_sr_lat.js +29 -21
- data/app/assets/javascripts/jquery.validate.localization/messages_sv.js +27 -19
- data/app/assets/javascripts/jquery.validate.localization/messages_th.js +29 -21
- data/app/assets/javascripts/jquery.validate.localization/messages_tj.js +29 -21
- data/app/assets/javascripts/jquery.validate.localization/messages_tr.js +29 -21
- data/app/assets/javascripts/jquery.validate.localization/messages_uk.js +29 -21
- data/app/assets/javascripts/jquery.validate.localization/messages_vi.js +29 -21
- data/app/assets/javascripts/jquery.validate.localization/messages_zh.js +29 -21
- data/app/assets/javascripts/jquery.validate.localization/messages_zh_TW.js +29 -21
- data/app/assets/javascripts/jquery.validate.localization/methods_de.js +11 -1
- data/app/assets/javascripts/jquery.validate.localization/methods_es_CL.js +11 -1
- data/app/assets/javascripts/jquery.validate.localization/methods_fi.js +22 -0
- data/app/assets/javascripts/jquery.validate.localization/methods_nl.js +11 -1
- data/app/assets/javascripts/jquery.validate.localization/methods_pt.js +11 -1
- data/lib/jquery/validation/rails/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4691809abf49bdbe7976df0d05ea7f7cbc626f20
|
4
|
+
data.tar.gz: 087209bab6f17cccb3c95cf47ae1d98f883e5613
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd3d64b8fe0c49136c4482107d68e3a461d0b88dfad33171c49c6c01fff65ab2cf16544b79fa2665cb3caf072f189ca57775dc5cfdd7521279b69960d0cf665c
|
7
|
+
data.tar.gz: 36b29911708276c3ceec81c33cb7d48b4978248ec1fdeafcc0d80cac3e892da17da15e6e89bea68e1b50c26a451b43717816b2bd7159075f2bd93f9e0c923ea0
|
data/CHANGELOG.md
CHANGED
@@ -1,11 +1,19 @@
|
|
1
1
|
/*!
|
2
|
-
* jQuery Validation Plugin v1.
|
2
|
+
* jQuery Validation Plugin v1.13.1
|
3
3
|
*
|
4
4
|
* http://jqueryvalidation.org/
|
5
5
|
*
|
6
6
|
* Copyright (c) 2014 Jörn Zaefferer
|
7
7
|
* Released under the MIT license
|
8
8
|
*/
|
9
|
+
(function( factory ) {
|
10
|
+
if ( typeof define === "function" && define.amd ) {
|
11
|
+
define( ["jquery", "./jquery.validate"], factory );
|
12
|
+
} else {
|
13
|
+
factory( jQuery );
|
14
|
+
}
|
15
|
+
}(function( $ ) {
|
16
|
+
|
9
17
|
(function() {
|
10
18
|
|
11
19
|
function stripHtml(value) {
|
@@ -15,24 +23,24 @@
|
|
15
23
|
.replace(/[.(),;:!?%#$'\"_+=\/\-“”’]*/g, "");
|
16
24
|
}
|
17
25
|
|
18
|
-
|
26
|
+
$.validator.addMethod("maxWords", function(value, element, params) {
|
19
27
|
return this.optional(element) || stripHtml(value).match(/\b\w+\b/g).length <= params;
|
20
|
-
},
|
28
|
+
}, $.validator.format("Please enter {0} words or less."));
|
21
29
|
|
22
|
-
|
30
|
+
$.validator.addMethod("minWords", function(value, element, params) {
|
23
31
|
return this.optional(element) || stripHtml(value).match(/\b\w+\b/g).length >= params;
|
24
|
-
},
|
32
|
+
}, $.validator.format("Please enter at least {0} words."));
|
25
33
|
|
26
|
-
|
34
|
+
$.validator.addMethod("rangeWords", function(value, element, params) {
|
27
35
|
var valueStripped = stripHtml(value),
|
28
36
|
regex = /\b\w+\b/g;
|
29
37
|
return this.optional(element) || valueStripped.match(regex).length >= params[0] && valueStripped.match(regex).length <= params[1];
|
30
|
-
},
|
38
|
+
}, $.validator.format("Please enter between {0} and {1} words."));
|
31
39
|
|
32
40
|
}());
|
33
41
|
|
34
42
|
// Accept a value from a file input based on a required mimetype
|
35
|
-
|
43
|
+
$.validator.addMethod("accept", function(value, element, param) {
|
36
44
|
// Split mime on commas in case we have multiple types we can accept
|
37
45
|
var typeParam = typeof param === "string" ? param.replace(/\s/g, "").replace(/,/g, "|") : "image/*",
|
38
46
|
optionalValue = this.optional(element),
|
@@ -43,7 +51,7 @@ jQuery.validator.addMethod("accept", function(value, element, param) {
|
|
43
51
|
return optionalValue;
|
44
52
|
}
|
45
53
|
|
46
|
-
if (
|
54
|
+
if ($(element).attr("type") === "file") {
|
47
55
|
// If we are using a wildcard, make it regex friendly
|
48
56
|
typeParam = typeParam.replace(/\*/g, ".*");
|
49
57
|
|
@@ -63,9 +71,9 @@ jQuery.validator.addMethod("accept", function(value, element, param) {
|
|
63
71
|
// Either return true because we've validated each file, or because the
|
64
72
|
// browser does not support element.files and the FileList feature
|
65
73
|
return true;
|
66
|
-
},
|
74
|
+
}, $.validator.format("Please enter a value with a valid mimetype."));
|
67
75
|
|
68
|
-
|
76
|
+
$.validator.addMethod("alphanumeric", function(value, element) {
|
69
77
|
return this.optional(element) || /^\w+$/i.test(value);
|
70
78
|
}, "Letters, numbers, and underscores only please");
|
71
79
|
|
@@ -75,7 +83,7 @@ jQuery.validator.addMethod("alphanumeric", function(value, element) {
|
|
75
83
|
* We accept the notation with spaces, as that is common.
|
76
84
|
* acceptable: 123456789 or 12 34 56 789
|
77
85
|
*/
|
78
|
-
|
86
|
+
$.validator.addMethod("bankaccountNL", function(value, element) {
|
79
87
|
if (this.optional(element)) {
|
80
88
|
return true;
|
81
89
|
}
|
@@ -95,7 +103,7 @@ jQuery.validator.addMethod("bankaccountNL", function(value, element) {
|
|
95
103
|
return sum % 11 === 0;
|
96
104
|
}, "Please specify a valid bank account number");
|
97
105
|
|
98
|
-
|
106
|
+
$.validator.addMethod("bankorgiroaccountNL", function(value, element) {
|
99
107
|
return this.optional(element) ||
|
100
108
|
($.validator.methods.bankaccountNL.call(this, value, element)) ||
|
101
109
|
($.validator.methods.giroaccountNL.call(this, value, element));
|
@@ -114,7 +122,7 @@ jQuery.validator.addMethod("bankorgiroaccountNL", function(value, element) {
|
|
114
122
|
* b. second character must be a letter ('O' is not allowed) or one of the following digits ('0' for test (therefore not allowed), '1' for passive participant and '2' for active participant)
|
115
123
|
* - Last 3 characters - branch code, optional (shall not start with 'X' except in case of 'XXX' for primary office) (letters and digits)
|
116
124
|
*/
|
117
|
-
|
125
|
+
$.validator.addMethod("bic", function(value, element) {
|
118
126
|
return this.optional( element ) || /^([A-Z]{6}[A-Z2-9][A-NP-Z1-2])(X{3}|[A-WY-Z0-9][A-Z0-9]{2})?$/.test( value );
|
119
127
|
}, "Please specify a valid BIC code");
|
120
128
|
|
@@ -122,7 +130,7 @@ jQuery.validator.addMethod("bic", function(value, element) {
|
|
122
130
|
* Código de identificación fiscal ( CIF ) is the tax identification code for Spanish legal entities
|
123
131
|
* Further rules can be found in Spanish on http://es.wikipedia.org/wiki/C%C3%B3digo_de_identificaci%C3%B3n_fiscal
|
124
132
|
*/
|
125
|
-
|
133
|
+
$.validator.addMethod( "cifES", function( value ) {
|
126
134
|
"use strict";
|
127
135
|
|
128
136
|
var num = [],
|
@@ -184,7 +192,7 @@ jQuery.validator.addMethod( "cifES", function( value ) {
|
|
184
192
|
* Redistributed under the the Apache License 2.0 at http://www.apache.org/licenses/LICENSE-2.0
|
185
193
|
* Valid Types: mastercard, visa, amex, dinersclub, enroute, discover, jcb, unknown, all (overrides all other settings)
|
186
194
|
*/
|
187
|
-
|
195
|
+
$.validator.addMethod("creditcardtypes", function(value, element, param) {
|
188
196
|
if (/[^0-9\-]+/.test(value)) {
|
189
197
|
return false;
|
190
198
|
}
|
@@ -278,7 +286,7 @@ jQuery.validator.addMethod("creditcardtypes", function(value, element, param) {
|
|
278
286
|
* currency: "$,£,¢"
|
279
287
|
* }
|
280
288
|
*/
|
281
|
-
|
289
|
+
$.validator.addMethod("currency", function(value, element, param) {
|
282
290
|
var isParamString = typeof param === "string",
|
283
291
|
symbol = isParamString ? param : param[0],
|
284
292
|
soft = isParamString ? true : param[1],
|
@@ -292,36 +300,40 @@ jQuery.validator.addMethod("currency", function(value, element, param) {
|
|
292
300
|
|
293
301
|
}, "Please specify a valid currency");
|
294
302
|
|
303
|
+
$.validator.addMethod("dateFA", function(value, element) {
|
304
|
+
return this.optional(element) || /^[1-4]\d{3}\/((0?[1-6]\/((3[0-1])|([1-2][0-9])|(0?[1-9])))|((1[0-2]|(0?[7-9]))\/(30|([1-2][0-9])|(0?[1-9]))))$/.test(value);
|
305
|
+
}, "Please enter a correct date");
|
306
|
+
|
295
307
|
/**
|
296
308
|
* Return true, if the value is a valid date, also making this formal check dd/mm/yyyy.
|
297
309
|
*
|
298
|
-
* @example
|
310
|
+
* @example $.validator.methods.date("01/01/1900")
|
299
311
|
* @result true
|
300
312
|
*
|
301
|
-
* @example
|
313
|
+
* @example $.validator.methods.date("01/13/1990")
|
302
314
|
* @result false
|
303
315
|
*
|
304
|
-
* @example
|
316
|
+
* @example $.validator.methods.date("01.01.1900")
|
305
317
|
* @result false
|
306
318
|
*
|
307
319
|
* @example <input name="pippo" class="{dateITA:true}" />
|
308
320
|
* @desc Declares an optional input element whose value must be a valid date.
|
309
321
|
*
|
310
|
-
* @name
|
322
|
+
* @name $.validator.methods.dateITA
|
311
323
|
* @type Boolean
|
312
324
|
* @cat Plugins/Validate/Methods
|
313
325
|
*/
|
314
|
-
|
326
|
+
$.validator.addMethod("dateITA", function(value, element) {
|
315
327
|
var check = false,
|
316
328
|
re = /^\d{1,2}\/\d{1,2}\/\d{4}$/,
|
317
329
|
adata, gg, mm, aaaa, xdata;
|
318
330
|
if ( re.test(value)) {
|
319
331
|
adata = value.split("/");
|
320
|
-
gg = parseInt(adata[0],10);
|
321
|
-
mm = parseInt(adata[1],10);
|
322
|
-
aaaa = parseInt(adata[2],10);
|
332
|
+
gg = parseInt(adata[0], 10);
|
333
|
+
mm = parseInt(adata[1], 10);
|
334
|
+
aaaa = parseInt(adata[2], 10);
|
323
335
|
xdata = new Date(aaaa, mm - 1, gg, 12, 0, 0, 0);
|
324
|
-
if ( ( xdata.
|
336
|
+
if ( ( xdata.getUTCFullYear() === aaaa ) && ( xdata.getUTCMonth () === mm - 1 ) && ( xdata.getUTCDate() === gg ) ) {
|
325
337
|
check = true;
|
326
338
|
} else {
|
327
339
|
check = false;
|
@@ -332,20 +344,20 @@ jQuery.validator.addMethod("dateITA", function(value, element) {
|
|
332
344
|
return this.optional(element) || check;
|
333
345
|
}, "Please enter a correct date");
|
334
346
|
|
335
|
-
|
347
|
+
$.validator.addMethod("dateNL", function(value, element) {
|
336
348
|
return this.optional(element) || /^(0?[1-9]|[12]\d|3[01])[\.\/\-](0?[1-9]|1[012])[\.\/\-]([12]\d)?(\d\d)$/.test(value);
|
337
349
|
}, "Please enter a correct date");
|
338
350
|
|
339
351
|
// Older "accept" file extension method. Old docs: http://docs.jquery.com/Plugins/Validation/Methods/accept
|
340
|
-
|
352
|
+
$.validator.addMethod("extension", function(value, element, param) {
|
341
353
|
param = typeof param === "string" ? param.replace(/,/g, "|") : "png|jpe?g|gif";
|
342
354
|
return this.optional(element) || value.match(new RegExp(".(" + param + ")$", "i"));
|
343
|
-
},
|
355
|
+
}, $.validator.format("Please enter a value with a valid extension."));
|
344
356
|
|
345
357
|
/**
|
346
358
|
* Dutch giro account numbers (not bank numbers) have max 7 digits
|
347
359
|
*/
|
348
|
-
|
360
|
+
$.validator.addMethod("giroaccountNL", function(value, element) {
|
349
361
|
return this.optional(element) || /^[0-9]{1,7}$/.test(value);
|
350
362
|
}, "Please specify a valid giro account number");
|
351
363
|
|
@@ -353,14 +365,14 @@ jQuery.validator.addMethod("giroaccountNL", function(value, element) {
|
|
353
365
|
* IBAN is the international bank account number.
|
354
366
|
* It has a country - specific format, that is checked here too
|
355
367
|
*/
|
356
|
-
|
368
|
+
$.validator.addMethod("iban", function(value, element) {
|
357
369
|
// some quick simple tests to prevent needless work
|
358
370
|
if (this.optional(element)) {
|
359
371
|
return true;
|
360
372
|
}
|
361
373
|
|
362
374
|
// remove spaces and to upper case
|
363
|
-
var iban = value.replace(/ /g,"").toUpperCase(),
|
375
|
+
var iban = value.replace(/ /g, "").toUpperCase(),
|
364
376
|
ibancheckdigits = "",
|
365
377
|
leadingZeroes = true,
|
366
378
|
cRest = "",
|
@@ -372,7 +384,7 @@ jQuery.validator.addMethod("iban", function(value, element) {
|
|
372
384
|
}
|
373
385
|
|
374
386
|
// check the country code and find the country specific format
|
375
|
-
countrycode = iban.substring(0,2);
|
387
|
+
countrycode = iban.substring(0, 2);
|
376
388
|
bbancountrypatterns = {
|
377
389
|
"AL": "\\d{8}[\\dA-Z]{16}",
|
378
390
|
"AD": "\\d{8}[\\dA-Z]{12}",
|
@@ -456,7 +468,7 @@ jQuery.validator.addMethod("iban", function(value, element) {
|
|
456
468
|
}
|
457
469
|
|
458
470
|
// now check the checksum, first convert to digits
|
459
|
-
ibancheck = iban.substring(4,iban.length) + iban.substring(0,4);
|
471
|
+
ibancheck = iban.substring(4, iban.length) + iban.substring(0, 4);
|
460
472
|
for (i = 0; i < ibancheck.length; i++) {
|
461
473
|
charAt = ibancheck.charAt(i);
|
462
474
|
if (charAt !== "0") {
|
@@ -476,27 +488,27 @@ jQuery.validator.addMethod("iban", function(value, element) {
|
|
476
488
|
return cRest === 1;
|
477
489
|
}, "Please specify a valid IBAN");
|
478
490
|
|
479
|
-
|
491
|
+
$.validator.addMethod("integer", function(value, element) {
|
480
492
|
return this.optional(element) || /^-?\d+$/.test(value);
|
481
493
|
}, "A positive or negative non-decimal number please");
|
482
494
|
|
483
|
-
|
495
|
+
$.validator.addMethod("ipv4", function(value, element) {
|
484
496
|
return this.optional(element) || /^(25[0-5]|2[0-4]\d|[01]?\d\d?)\.(25[0-5]|2[0-4]\d|[01]?\d\d?)\.(25[0-5]|2[0-4]\d|[01]?\d\d?)\.(25[0-5]|2[0-4]\d|[01]?\d\d?)$/i.test(value);
|
485
497
|
}, "Please enter a valid IP v4 address.");
|
486
498
|
|
487
|
-
|
499
|
+
$.validator.addMethod("ipv6", function(value, element) {
|
488
500
|
return this.optional(element) || /^((([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(([0-9A-Fa-f]{1,4}:){0,5}:((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(::([0-9A-Fa-f]{1,4}:){0,5}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:))$/i.test(value);
|
489
501
|
}, "Please enter a valid IP v6 address.");
|
490
502
|
|
491
|
-
|
503
|
+
$.validator.addMethod("lettersonly", function(value, element) {
|
492
504
|
return this.optional(element) || /^[a-z]+$/i.test(value);
|
493
505
|
}, "Letters only please");
|
494
506
|
|
495
|
-
|
507
|
+
$.validator.addMethod("letterswithbasicpunc", function(value, element) {
|
496
508
|
return this.optional(element) || /^[a-z\-.,()'"\s]+$/i.test(value);
|
497
509
|
}, "Letters or punctuation only please");
|
498
510
|
|
499
|
-
|
511
|
+
$.validator.addMethod("mobileNL", function(value, element) {
|
500
512
|
return this.optional(element) || /^((\+|00(\s|\s?\-\s?)?)31(\s|\s?\-\s?)?(\(0\)[\-\s]?)?|0)6((\s|\s?\-\s?)?[0-9]){8}$/.test(value);
|
501
513
|
}, "Please specify a valid mobile number");
|
502
514
|
|
@@ -508,7 +520,7 @@ jQuery.validator.addMethod("mobileNL", function(value, element) {
|
|
508
520
|
* A number of very detailed GB telephone number RegEx patterns can also be found at:
|
509
521
|
* http://www.aa-asterisk.org.uk/index.php/Regular_Expressions_for_Validating_and_Formatting_GB_Telephone_Numbers
|
510
522
|
*/
|
511
|
-
|
523
|
+
$.validator.addMethod("mobileUK", function(phone_number, element) {
|
512
524
|
phone_number = phone_number.replace(/\(|\)|\s+|-/g, "");
|
513
525
|
return this.optional(element) || phone_number.length > 9 &&
|
514
526
|
phone_number.match(/^(?:(?:(?:00\s?|\+)44\s?|0)7(?:[1345789]\d{2}|624)\s?\d{3}\s?\d{3})$/);
|
@@ -517,7 +529,7 @@ jQuery.validator.addMethod("mobileUK", function(phone_number, element) {
|
|
517
529
|
/*
|
518
530
|
* The número de identidad de extranjero ( NIE )is a code used to identify the non-nationals in Spain
|
519
531
|
*/
|
520
|
-
|
532
|
+
$.validator.addMethod( "nieES", function( value ) {
|
521
533
|
"use strict";
|
522
534
|
|
523
535
|
value = value.toUpperCase();
|
@@ -552,7 +564,7 @@ jQuery.validator.addMethod( "nieES", function( value ) {
|
|
552
564
|
/*
|
553
565
|
* The Número de Identificación Fiscal ( NIF ) is the way tax identification used in Spain for individuals
|
554
566
|
*/
|
555
|
-
|
567
|
+
$.validator.addMethod( "nifES", function( value ) {
|
556
568
|
"use strict";
|
557
569
|
|
558
570
|
value = value.toUpperCase();
|
@@ -575,29 +587,29 @@ jQuery.validator.addMethod( "nifES", function( value ) {
|
|
575
587
|
|
576
588
|
}, "Please specify a valid NIF number." );
|
577
589
|
|
578
|
-
|
590
|
+
$.validator.addMethod("nowhitespace", function(value, element) {
|
579
591
|
return this.optional(element) || /^\S+$/i.test(value);
|
580
592
|
}, "No white space please");
|
581
593
|
|
582
594
|
/**
|
583
595
|
* Return true if the field value matches the given format RegExp
|
584
596
|
*
|
585
|
-
* @example
|
597
|
+
* @example $.validator.methods.pattern("AR1004",element,/^AR\d{4}$/)
|
586
598
|
* @result true
|
587
599
|
*
|
588
|
-
* @example
|
600
|
+
* @example $.validator.methods.pattern("BR1004",element,/^AR\d{4}$/)
|
589
601
|
* @result false
|
590
602
|
*
|
591
|
-
* @name
|
603
|
+
* @name $.validator.methods.pattern
|
592
604
|
* @type Boolean
|
593
605
|
* @cat Plugins/Validate/Methods
|
594
606
|
*/
|
595
|
-
|
607
|
+
$.validator.addMethod("pattern", function(value, element, param) {
|
596
608
|
if (this.optional(element)) {
|
597
609
|
return true;
|
598
610
|
}
|
599
611
|
if (typeof param === "string") {
|
600
|
-
param = new RegExp(param);
|
612
|
+
param = new RegExp("^(?:" + param + ")$");
|
601
613
|
}
|
602
614
|
return param.test(value);
|
603
615
|
}, "Invalid format.");
|
@@ -605,7 +617,7 @@ jQuery.validator.addMethod("pattern", function(value, element, param) {
|
|
605
617
|
/**
|
606
618
|
* Dutch phone numbers have 10 digits (or 11 and start with +31).
|
607
619
|
*/
|
608
|
-
|
620
|
+
$.validator.addMethod("phoneNL", function(value, element) {
|
609
621
|
return this.optional(element) || /^((\+|00(\s|\s?\-\s?)?)31(\s|\s?\-\s?)?(\(0\)[\-\s]?)?|0)[1-9]((\s|\s?\-\s?)?[0-9]){8}$/.test(value);
|
610
622
|
}, "Please specify a valid phone number.");
|
611
623
|
|
@@ -617,7 +629,7 @@ jQuery.validator.addMethod("phoneNL", function(value, element) {
|
|
617
629
|
* A number of very detailed GB telephone number RegEx patterns can also be found at:
|
618
630
|
* http://www.aa-asterisk.org.uk/index.php/Regular_Expressions_for_Validating_and_Formatting_GB_Telephone_Numbers
|
619
631
|
*/
|
620
|
-
|
632
|
+
$.validator.addMethod("phoneUK", function(phone_number, element) {
|
621
633
|
phone_number = phone_number.replace(/\(|\)|\s+|-/g, "");
|
622
634
|
return this.optional(element) || phone_number.length > 9 &&
|
623
635
|
phone_number.match(/^(?:(?:(?:00\s?|\+)44\s?)|(?:\(?0))(?:\d{2}\)?\s?\d{4}\s?\d{4}|\d{3}\)?\s?\d{3}\s?\d{3,4}|\d{4}\)?\s?(?:\d{5}|\d{3}\s?\d{3})|\d{5}\)?\s?\d{4,5})$/);
|
@@ -639,7 +651,7 @@ jQuery.validator.addMethod("phoneUK", function(phone_number, element) {
|
|
639
651
|
* and not
|
640
652
|
* 212 123 4567
|
641
653
|
*/
|
642
|
-
|
654
|
+
$.validator.addMethod("phoneUS", function(phone_number, element) {
|
643
655
|
phone_number = phone_number.replace(/\s+/g, "");
|
644
656
|
return this.optional(element) || phone_number.length > 9 &&
|
645
657
|
phone_number.match(/^(\+?1-?)?(\([2-9]([02-9]\d|1[02-9])\)|[2-9]([02-9]\d|1[02-9]))-?[2-9]([02-9]\d|1[02-9])-?\d{4}$/);
|
@@ -654,18 +666,52 @@ jQuery.validator.addMethod("phoneUS", function(phone_number, element) {
|
|
654
666
|
* http://www.aa-asterisk.org.uk/index.php/Regular_Expressions_for_Validating_and_Formatting_GB_Telephone_Numbers
|
655
667
|
*/
|
656
668
|
//Matches UK landline + mobile, accepting only 01-3 for landline or 07 for mobile to exclude many premium numbers
|
657
|
-
|
669
|
+
$.validator.addMethod("phonesUK", function(phone_number, element) {
|
658
670
|
phone_number = phone_number.replace(/\(|\)|\s+|-/g, "");
|
659
671
|
return this.optional(element) || phone_number.length > 9 &&
|
660
672
|
phone_number.match(/^(?:(?:(?:00\s?|\+)44\s?|0)(?:1\d{8,9}|[23]\d{9}|7(?:[1345789]\d{8}|624\d{6})))$/);
|
661
673
|
}, "Please specify a valid uk phone number");
|
662
674
|
|
663
|
-
|
675
|
+
/**
|
676
|
+
* Matches a valid Canadian Postal Code
|
677
|
+
*
|
678
|
+
* @example jQuery.validator.methods.postalCodeCA( "H0H 0H0", element )
|
679
|
+
* @result true
|
680
|
+
*
|
681
|
+
* @example jQuery.validator.methods.postalCodeCA( "H0H0H0", element )
|
682
|
+
* @result false
|
683
|
+
*
|
684
|
+
* @name jQuery.validator.methods.postalCodeCA
|
685
|
+
* @type Boolean
|
686
|
+
* @cat Plugins/Validate/Methods
|
687
|
+
*/
|
688
|
+
$.validator.addMethod( "postalCodeCA", function( value, element ) {
|
689
|
+
return this.optional( element ) || /^[ABCEGHJKLMNPRSTVXY]\d[A-Z] \d[A-Z]\d$/.test( value );
|
690
|
+
}, "Please specify a valid postal code" );
|
691
|
+
|
692
|
+
/*
|
693
|
+
* Valida CEPs do brasileiros:
|
694
|
+
*
|
695
|
+
* Formatos aceitos:
|
696
|
+
* 99999-999
|
697
|
+
* 99.999-999
|
698
|
+
* 99999999
|
699
|
+
*/
|
700
|
+
$.validator.addMethod("postalcodeBR", function(cep_value, element) {
|
701
|
+
return this.optional(element) || /^\d{2}.\d{3}-\d{3}?$|^\d{5}-?\d{3}?$/.test( cep_value );
|
702
|
+
}, "Informe um CEP válido.");
|
703
|
+
|
704
|
+
/* Matches Italian postcode (CAP) */
|
705
|
+
$.validator.addMethod("postalcodeIT", function(value, element) {
|
706
|
+
return this.optional(element) || /^\d{5}$/.test(value);
|
707
|
+
}, "Please specify a valid postal code");
|
708
|
+
|
709
|
+
$.validator.addMethod("postalcodeNL", function(value, element) {
|
664
710
|
return this.optional(element) || /^[1-9][0-9]{3}\s?[a-zA-Z]{2}$/.test(value);
|
665
711
|
}, "Please specify a valid postal code");
|
666
712
|
|
667
713
|
// Matches UK postcode. Does not match to UK Channel Islands that have their own postcodes (non standard UK)
|
668
|
-
|
714
|
+
$.validator.addMethod("postcodeUK", function(value, element) {
|
669
715
|
return this.optional(element) || /^((([A-PR-UWYZ][0-9])|([A-PR-UWYZ][0-9][0-9])|([A-PR-UWYZ][A-HK-Y][0-9])|([A-PR-UWYZ][A-HK-Y][0-9][0-9])|([A-PR-UWYZ][0-9][A-HJKSTUW])|([A-PR-UWYZ][A-HK-Y][0-9][ABEHMNPRVWXY]))\s?([0-9][ABD-HJLNP-UW-Z]{2})|(GIR)\s?(0AA))$/i.test(value);
|
670
716
|
}, "Please specify a valid UK postcode");
|
671
717
|
|
@@ -685,7 +731,7 @@ jQuery.validator.addMethod("postcodeUK", function(value, element) {
|
|
685
731
|
* options[0]: number of fields that must be filled in the group
|
686
732
|
* options[1]: CSS selector that defines the group of conditionally required fields
|
687
733
|
*/
|
688
|
-
|
734
|
+
$.validator.addMethod("require_from_group", function(value, element, options) {
|
689
735
|
var $fields = $(options[1], element.form),
|
690
736
|
$fieldsFirst = $fields.eq(0),
|
691
737
|
validator = $fieldsFirst.data("valid_req_grp") ? $fieldsFirst.data("valid_req_grp") : $.extend({}, this),
|
@@ -705,7 +751,7 @@ jQuery.validator.addMethod("require_from_group", function(value, element, option
|
|
705
751
|
$fields.data("being_validated", false);
|
706
752
|
}
|
707
753
|
return isValid;
|
708
|
-
},
|
754
|
+
}, $.validator.format("Please fill at least {0} of these fields."));
|
709
755
|
|
710
756
|
/*
|
711
757
|
* Lets you say "either at least X inputs that match selector Y must be filled,
|
@@ -728,7 +774,7 @@ jQuery.validator.addMethod("require_from_group", function(value, element, option
|
|
728
774
|
* options[1]: CSS selector that defines the group of conditionally required fields
|
729
775
|
*
|
730
776
|
*/
|
731
|
-
|
777
|
+
$.validator.addMethod("skip_or_fill_minimum", function(value, element, options) {
|
732
778
|
var $fields = $(options[1], element.form),
|
733
779
|
$fieldsFirst = $fields.eq(0),
|
734
780
|
validator = $fieldsFirst.data("valid_skip") ? $fieldsFirst.data("valid_skip") : $.extend({}, this),
|
@@ -749,25 +795,84 @@ jQuery.validator.addMethod("skip_or_fill_minimum", function(value, element, opti
|
|
749
795
|
$fields.data("being_validated", false);
|
750
796
|
}
|
751
797
|
return isValid;
|
752
|
-
},
|
798
|
+
}, $.validator.format("Please either skip these fields or fill at least {0} of them."));
|
799
|
+
|
800
|
+
/* Validates US States and/or Territories by @jdforsythe
|
801
|
+
* Can be case insensitive or require capitalization - default is case insensitive
|
802
|
+
* Can include US Territories or not - default does not
|
803
|
+
* Can include US Military postal abbreviations (AA, AE, AP) - default does not
|
804
|
+
*
|
805
|
+
* Note: "States" always includes DC (District of Colombia)
|
806
|
+
*
|
807
|
+
* Usage examples:
|
808
|
+
*
|
809
|
+
* This is the default - case insensitive, no territories, no military zones
|
810
|
+
* stateInput: {
|
811
|
+
* caseSensitive: false,
|
812
|
+
* includeTerritories: false,
|
813
|
+
* includeMilitary: false
|
814
|
+
* }
|
815
|
+
*
|
816
|
+
* Only allow capital letters, no territories, no military zones
|
817
|
+
* stateInput: {
|
818
|
+
* caseSensitive: false
|
819
|
+
* }
|
820
|
+
*
|
821
|
+
* Case insensitive, include territories but not military zones
|
822
|
+
* stateInput: {
|
823
|
+
* includeTerritories: true
|
824
|
+
* }
|
825
|
+
*
|
826
|
+
* Only allow capital letters, include territories and military zones
|
827
|
+
* stateInput: {
|
828
|
+
* caseSensitive: true,
|
829
|
+
* includeTerritories: true,
|
830
|
+
* includeMilitary: true
|
831
|
+
* }
|
832
|
+
*
|
833
|
+
*
|
834
|
+
*
|
835
|
+
*/
|
836
|
+
|
837
|
+
jQuery.validator.addMethod("stateUS", function(value, element, options) {
|
838
|
+
var isDefault = typeof options === "undefined",
|
839
|
+
caseSensitive = ( isDefault || typeof options.caseSensitive === "undefined" ) ? false : options.caseSensitive,
|
840
|
+
includeTerritories = ( isDefault || typeof options.includeTerritories === "undefined" ) ? false : options.includeTerritories,
|
841
|
+
includeMilitary = ( isDefault || typeof options.includeMilitary === "undefined" ) ? false : options.includeMilitary,
|
842
|
+
regex;
|
843
|
+
|
844
|
+
if (!includeTerritories && !includeMilitary) {
|
845
|
+
regex = "^(A[KLRZ]|C[AOT]|D[CE]|FL|GA|HI|I[ADLN]|K[SY]|LA|M[ADEINOST]|N[CDEHJMVY]|O[HKR]|PA|RI|S[CD]|T[NX]|UT|V[AT]|W[AIVY])$";
|
846
|
+
} else if (includeTerritories && includeMilitary) {
|
847
|
+
regex = "^(A[AEKLPRSZ]|C[AOT]|D[CE]|FL|G[AU]|HI|I[ADLN]|K[SY]|LA|M[ADEINOPST]|N[CDEHJMVY]|O[HKR]|P[AR]|RI|S[CD]|T[NX]|UT|V[AIT]|W[AIVY])$";
|
848
|
+
} else if (includeTerritories) {
|
849
|
+
regex = "^(A[KLRSZ]|C[AOT]|D[CE]|FL|G[AU]|HI|I[ADLN]|K[SY]|LA|M[ADEINOPST]|N[CDEHJMVY]|O[HKR]|P[AR]|RI|S[CD]|T[NX]|UT|V[AIT]|W[AIVY])$";
|
850
|
+
} else {
|
851
|
+
regex = "^(A[AEKLPRZ]|C[AOT]|D[CE]|FL|GA|HI|I[ADLN]|K[SY]|LA|M[ADEINOST]|N[CDEHJMVY]|O[HKR]|PA|RI|S[CD]|T[NX]|UT|V[AT]|W[AIVY])$";
|
852
|
+
}
|
853
|
+
|
854
|
+
regex = caseSensitive ? new RegExp(regex) : new RegExp(regex, "i");
|
855
|
+
return this.optional(element) || regex.test(value);
|
856
|
+
},
|
857
|
+
"Please specify a valid state");
|
753
858
|
|
754
859
|
// TODO check if value starts with <, otherwise don't try stripping anything
|
755
|
-
|
756
|
-
return
|
757
|
-
},
|
860
|
+
$.validator.addMethod("strippedminlength", function(value, element, param) {
|
861
|
+
return $(value).text().length >= param;
|
862
|
+
}, $.validator.format("Please enter at least {0} characters"));
|
758
863
|
|
759
|
-
|
864
|
+
$.validator.addMethod("time", function(value, element) {
|
760
865
|
return this.optional(element) || /^([01]\d|2[0-3])(:[0-5]\d){1,2}$/.test(value);
|
761
866
|
}, "Please enter a valid time, between 00:00 and 23:59");
|
762
867
|
|
763
|
-
|
868
|
+
$.validator.addMethod("time12h", function(value, element) {
|
764
869
|
return this.optional(element) || /^((0?[1-9]|1[012])(:[0-5]\d){1,2}(\ ?[AP]M))$/i.test(value);
|
765
870
|
}, "Please enter a valid time in 12-hour am/pm format");
|
766
871
|
|
767
872
|
// same as url, but TLD is optional
|
768
|
-
|
873
|
+
$.validator.addMethod("url2", function(value, element) {
|
769
874
|
return this.optional(element) || /^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[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])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(value);
|
770
|
-
},
|
875
|
+
}, $.validator.messages.url);
|
771
876
|
|
772
877
|
/**
|
773
878
|
* Return true, if the value is a valid vehicle identification number (VIN).
|
@@ -777,11 +882,11 @@ jQuery.validator.addMethod("url2", function(value, element) {
|
|
777
882
|
* @example <input type="text" size="20" name="VehicleID" class="{required:true,vinUS:true}" />
|
778
883
|
* @desc Declares a required input element whose value must be a valid vehicle identification number.
|
779
884
|
*
|
780
|
-
* @name
|
885
|
+
* @name $.validator.methods.vinUS
|
781
886
|
* @type Boolean
|
782
887
|
* @cat Plugins/Validate/Methods
|
783
888
|
*/
|
784
|
-
|
889
|
+
$.validator.addMethod("vinUS", function(v) {
|
785
890
|
if (v.length !== 17) {
|
786
891
|
return false;
|
787
892
|
}
|
@@ -792,9 +897,9 @@ jQuery.validator.addMethod("vinUS", function(v) {
|
|
792
897
|
rs = 0,
|
793
898
|
i, n, d, f, cd, cdv;
|
794
899
|
|
795
|
-
for (i = 0; i < 17; i++){
|
900
|
+
for (i = 0; i < 17; i++) {
|
796
901
|
f = FL[i];
|
797
|
-
d = v.slice(i,i + 1);
|
902
|
+
d = v.slice(i, i + 1);
|
798
903
|
if (i === 8) {
|
799
904
|
cdv = d;
|
800
905
|
}
|
@@ -824,10 +929,12 @@ jQuery.validator.addMethod("vinUS", function(v) {
|
|
824
929
|
return false;
|
825
930
|
}, "The specified vehicle identification number (VIN) is invalid.");
|
826
931
|
|
827
|
-
|
828
|
-
return this.optional(element) || /^\d{5}-\d{4}
|
932
|
+
$.validator.addMethod("zipcodeUS", function(value, element) {
|
933
|
+
return this.optional(element) || /^\d{5}(-\d{4})?$/.test(value);
|
829
934
|
}, "The specified US ZIP Code is invalid");
|
830
935
|
|
831
|
-
|
936
|
+
$.validator.addMethod("ziprange", function(value, element) {
|
832
937
|
return this.optional(element) || /^90[2-5]\d\{2\}-\d{4}$/.test(value);
|
833
|
-
}, "Your ZIP-code must be in the range 902xx-xxxx to
|
938
|
+
}, "Your ZIP-code must be in the range 902xx-xxxx to 905xx-xxxx");
|
939
|
+
|
940
|
+
}));
|