jquery-validation-rails 1.11.0 → 1.11.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 +7 -0
- data/README.md +5 -1
- data/lib/jquery/validation/rails/version.rb +1 -1
- data/vendor/assets/javascripts/jquery.validate.additional-methods.js +197 -24
- data/vendor/assets/javascripts/jquery.validate.js +123 -99
- data/vendor/assets/javascripts/jquery.validate.localization/messages_ar.js +25 -0
- data/vendor/assets/javascripts/jquery.validate.localization/messages_bg.js +25 -0
- data/vendor/assets/javascripts/jquery.validate.localization/messages_ca.js +25 -0
- data/vendor/assets/javascripts/jquery.validate.localization/messages_cs.js +25 -0
- data/vendor/assets/javascripts/jquery.validate.localization/messages_da.js +22 -0
- data/vendor/assets/javascripts/jquery.validate.localization/messages_de.js +22 -0
- data/vendor/assets/javascripts/jquery.validate.localization/messages_el.js +25 -0
- data/vendor/assets/javascripts/jquery.validate.localization/messages_es.js +25 -0
- data/vendor/assets/javascripts/jquery.validate.localization/messages_et.js +23 -0
- data/vendor/assets/javascripts/jquery.validate.localization/messages_eu.js +25 -0
- data/vendor/assets/javascripts/jquery.validate.localization/messages_fa.js +25 -0
- data/vendor/assets/javascripts/jquery.validate.localization/messages_fi.js +23 -0
- data/vendor/assets/javascripts/jquery.validate.localization/messages_fr.js +47 -0
- data/vendor/assets/javascripts/jquery.validate.localization/messages_he.js +25 -0
- data/vendor/assets/javascripts/jquery.validate.localization/messages_hr.js +25 -0
- data/vendor/assets/javascripts/jquery.validate.localization/messages_hu.js +24 -0
- data/vendor/assets/javascripts/jquery.validate.localization/messages_it.js +25 -0
- data/vendor/assets/javascripts/jquery.validate.localization/messages_ja.js +25 -0
- data/vendor/assets/javascripts/jquery.validate.localization/messages_ka.js +25 -0
- data/vendor/assets/javascripts/jquery.validate.localization/messages_kk.js +25 -0
- data/vendor/assets/javascripts/jquery.validate.localization/messages_ko.js +25 -0
- data/vendor/assets/javascripts/jquery.validate.localization/messages_lt.js +25 -0
- data/vendor/assets/javascripts/jquery.validate.localization/messages_lv.js +25 -0
- data/vendor/assets/javascripts/jquery.validate.localization/messages_my.js +25 -0
- data/vendor/assets/javascripts/jquery.validate.localization/messages_nl.js +35 -0
- data/vendor/assets/javascripts/jquery.validate.localization/messages_no.js +25 -0
- data/vendor/assets/javascripts/jquery.validate.localization/messages_pl.js +25 -0
- data/vendor/assets/javascripts/jquery.validate.localization/messages_pt_BR.js +26 -0
- data/vendor/assets/javascripts/jquery.validate.localization/messages_pt_PT.js +26 -0
- data/vendor/assets/javascripts/jquery.validate.localization/messages_ro.js +25 -0
- data/vendor/assets/javascripts/jquery.validate.localization/messages_ru.js +25 -0
- data/vendor/assets/javascripts/jquery.validate.localization/messages_si.js +25 -0
- data/vendor/assets/javascripts/jquery.validate.localization/messages_sk.js +22 -0
- data/vendor/assets/javascripts/jquery.validate.localization/messages_sl.js +25 -0
- data/vendor/assets/javascripts/jquery.validate.localization/messages_sr.js +25 -0
- data/vendor/assets/javascripts/jquery.validate.localization/messages_sv.js +23 -0
- data/vendor/assets/javascripts/jquery.validate.localization/messages_th.js +25 -0
- data/vendor/assets/javascripts/jquery.validate.localization/messages_tr.js +25 -0
- data/vendor/assets/javascripts/jquery.validate.localization/messages_uk.js +25 -0
- data/vendor/assets/javascripts/jquery.validate.localization/messages_vi.js +25 -0
- data/vendor/assets/javascripts/jquery.validate.localization/messages_zh.js +25 -0
- data/vendor/assets/javascripts/jquery.validate.localization/messages_zh_TW.js +26 -0
- data/vendor/assets/javascripts/jquery.validate.localization/methods_de.js +12 -0
- data/vendor/assets/javascripts/jquery.validate.localization/methods_nl.js +9 -0
- data/vendor/assets/javascripts/jquery.validate.localization/methods_pt.js +9 -0
- metadata +52 -21
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 613e5db18d65aea37fc5a4c15466165b27932315
|
4
|
+
data.tar.gz: b895585b8fe6d5f854f85e2b07552e8dccdfe788
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 52712b965f5510bceeaf0acf213eda40031e707d27e134714ff7cb8e581bcc946d7c558e5a9fee64a14fbe53e1c81fb571b1b85b067adbb8b7e161d403c06a46
|
7
|
+
data.tar.gz: e627c066d553dc7c0876b8c1198d0f2174a3c306b9a1aab48fdf9ea55819de3c4a9b444ee5c5c822197c37c20240a0f961ab0943907bf0579fd939d6cbf45898
|
data/README.md
CHANGED
@@ -15,13 +15,17 @@ Add `jquery-validation-rails` to your Gemfile and run `bundle install`:
|
|
15
15
|
|
16
16
|
gem "jquery-validation-rails"
|
17
17
|
|
18
|
-
### Include
|
18
|
+
### Include jquery-validation-rails javascript assets
|
19
19
|
|
20
20
|
Add the following to your `app/assets/javascripts/application.js`:
|
21
21
|
|
22
22
|
//= require jquery.validate
|
23
23
|
//= require jquery.validate.additional-methods
|
24
24
|
|
25
|
+
Localization:
|
26
|
+
|
27
|
+
//= require jquery.validate.localization/messages_XX
|
28
|
+
|
25
29
|
## Contributing
|
26
30
|
|
27
31
|
1. Fork it
|
@@ -1,9 +1,5 @@
|
|
1
|
-
/*! jQuery Validation Plugin - v1.11.0 - 2/4/2013
|
2
|
-
* https://github.com/jzaefferer/jquery-validation
|
3
|
-
* Copyright (c) 2013 Jörn Zaefferer; Licensed MIT */
|
4
|
-
|
5
1
|
/*!
|
6
|
-
* jQuery Validation Plugin 1.11.
|
2
|
+
* jQuery Validation Plugin 1.11.1
|
7
3
|
*
|
8
4
|
* http://bassistance.de/jquery-plugins/jquery-plugin-validation/
|
9
5
|
* http://docs.jquery.com/Plugins/Validation
|
@@ -157,16 +153,193 @@ jQuery.validator.addMethod("dateITA", function(value, element) {
|
|
157
153
|
return this.optional(element) || check;
|
158
154
|
}, "Please enter a correct date");
|
159
155
|
|
156
|
+
/**
|
157
|
+
* IBAN is the international bank account number.
|
158
|
+
* It has a country - specific format, that is checked here too
|
159
|
+
*/
|
160
|
+
jQuery.validator.addMethod("iban", function(value, element) {
|
161
|
+
// some quick simple tests to prevent needless work
|
162
|
+
if (this.optional(element)) {
|
163
|
+
return true;
|
164
|
+
}
|
165
|
+
if (!(/^([a-zA-Z0-9]{4} ){2,8}[a-zA-Z0-9]{1,4}|[a-zA-Z0-9]{12,34}$/.test(value))) {
|
166
|
+
return false;
|
167
|
+
}
|
168
|
+
|
169
|
+
// check the country code and find the country specific format
|
170
|
+
var iban = value.replace(/ /g,'').toUpperCase(); // remove spaces and to upper case
|
171
|
+
var countrycode = iban.substring(0,2);
|
172
|
+
var bbancountrypatterns = {
|
173
|
+
'AL': "\\d{8}[\\dA-Z]{16}",
|
174
|
+
'AD': "\\d{8}[\\dA-Z]{12}",
|
175
|
+
'AT': "\\d{16}",
|
176
|
+
'AZ': "[\\dA-Z]{4}\\d{20}",
|
177
|
+
'BE': "\\d{12}",
|
178
|
+
'BH': "[A-Z]{4}[\\dA-Z]{14}",
|
179
|
+
'BA': "\\d{16}",
|
180
|
+
'BR': "\\d{23}[A-Z][\\dA-Z]",
|
181
|
+
'BG': "[A-Z]{4}\\d{6}[\\dA-Z]{8}",
|
182
|
+
'CR': "\\d{17}",
|
183
|
+
'HR': "\\d{17}",
|
184
|
+
'CY': "\\d{8}[\\dA-Z]{16}",
|
185
|
+
'CZ': "\\d{20}",
|
186
|
+
'DK': "\\d{14}",
|
187
|
+
'DO': "[A-Z]{4}\\d{20}",
|
188
|
+
'EE': "\\d{16}",
|
189
|
+
'FO': "\\d{14}",
|
190
|
+
'FI': "\\d{14}",
|
191
|
+
'FR': "\\d{10}[\\dA-Z]{11}\\d{2}",
|
192
|
+
'GE': "[\\dA-Z]{2}\\d{16}",
|
193
|
+
'DE': "\\d{18}",
|
194
|
+
'GI': "[A-Z]{4}[\\dA-Z]{15}",
|
195
|
+
'GR': "\\d{7}[\\dA-Z]{16}",
|
196
|
+
'GL': "\\d{14}",
|
197
|
+
'GT': "[\\dA-Z]{4}[\\dA-Z]{20}",
|
198
|
+
'HU': "\\d{24}",
|
199
|
+
'IS': "\\d{22}",
|
200
|
+
'IE': "[\\dA-Z]{4}\\d{14}",
|
201
|
+
'IL': "\\d{19}",
|
202
|
+
'IT': "[A-Z]\\d{10}[\\dA-Z]{12}",
|
203
|
+
'KZ': "\\d{3}[\\dA-Z]{13}",
|
204
|
+
'KW': "[A-Z]{4}[\\dA-Z]{22}",
|
205
|
+
'LV': "[A-Z]{4}[\\dA-Z]{13}",
|
206
|
+
'LB': "\\d{4}[\\dA-Z]{20}",
|
207
|
+
'LI': "\\d{5}[\\dA-Z]{12}",
|
208
|
+
'LT': "\\d{16}",
|
209
|
+
'LU': "\\d{3}[\\dA-Z]{13}",
|
210
|
+
'MK': "\\d{3}[\\dA-Z]{10}\\d{2}",
|
211
|
+
'MT': "[A-Z]{4}\\d{5}[\\dA-Z]{18}",
|
212
|
+
'MR': "\\d{23}",
|
213
|
+
'MU': "[A-Z]{4}\\d{19}[A-Z]{3}",
|
214
|
+
'MC': "\\d{10}[\\dA-Z]{11}\\d{2}",
|
215
|
+
'MD': "[\\dA-Z]{2}\\d{18}",
|
216
|
+
'ME': "\\d{18}",
|
217
|
+
'NL': "[A-Z]{4}\\d{10}",
|
218
|
+
'NO': "\\d{11}",
|
219
|
+
'PK': "[\\dA-Z]{4}\\d{16}",
|
220
|
+
'PS': "[\\dA-Z]{4}\\d{21}",
|
221
|
+
'PL': "\\d{24}",
|
222
|
+
'PT': "\\d{21}",
|
223
|
+
'RO': "[A-Z]{4}[\\dA-Z]{16}",
|
224
|
+
'SM': "[A-Z]\\d{10}[\\dA-Z]{12}",
|
225
|
+
'SA': "\\d{2}[\\dA-Z]{18}",
|
226
|
+
'RS': "\\d{18}",
|
227
|
+
'SK': "\\d{20}",
|
228
|
+
'SI': "\\d{15}",
|
229
|
+
'ES': "\\d{20}",
|
230
|
+
'SE': "\\d{20}",
|
231
|
+
'CH': "\\d{5}[\\dA-Z]{12}",
|
232
|
+
'TN': "\\d{20}",
|
233
|
+
'TR': "\\d{5}[\\dA-Z]{17}",
|
234
|
+
'AE': "\\d{3}\\d{16}",
|
235
|
+
'GB': "[A-Z]{4}\\d{14}",
|
236
|
+
'VG': "[\\dA-Z]{4}\\d{16}"
|
237
|
+
};
|
238
|
+
var bbanpattern = bbancountrypatterns[countrycode];
|
239
|
+
// As new countries will start using IBAN in the
|
240
|
+
// future, we only check if the countrycode is known.
|
241
|
+
// This prevents false negatives, while almost all
|
242
|
+
// false positives introduced by this, will be caught
|
243
|
+
// by the checksum validation below anyway.
|
244
|
+
// Strict checking should return FALSE for unknown
|
245
|
+
// countries.
|
246
|
+
if (typeof bbanpattern !== 'undefined') {
|
247
|
+
var ibanregexp = new RegExp("^[A-Z]{2}\\d{2}" + bbanpattern + "$", "");
|
248
|
+
if (!(ibanregexp.test(iban))) {
|
249
|
+
return false; // invalid country specific format
|
250
|
+
}
|
251
|
+
}
|
252
|
+
|
253
|
+
// now check the checksum, first convert to digits
|
254
|
+
var ibancheck = iban.substring(4,iban.length) + iban.substring(0,4);
|
255
|
+
var ibancheckdigits = "";
|
256
|
+
var leadingZeroes = true;
|
257
|
+
var charAt;
|
258
|
+
for (var i =0; i<ibancheck.length; i++) {
|
259
|
+
charAt = ibancheck.charAt(i);
|
260
|
+
if (charAt !== "0") {
|
261
|
+
leadingZeroes = false;
|
262
|
+
}
|
263
|
+
if (!leadingZeroes) {
|
264
|
+
ibancheckdigits += "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ".indexOf(charAt);
|
265
|
+
}
|
266
|
+
}
|
267
|
+
|
268
|
+
// calculate the result of: ibancheckdigits % 97
|
269
|
+
var cRest = '';
|
270
|
+
var cOperator = '';
|
271
|
+
for (var p=0; p<ibancheckdigits.length; p++) {
|
272
|
+
var cChar = ibancheckdigits.charAt(p);
|
273
|
+
cOperator = '' + cRest + '' + cChar;
|
274
|
+
cRest = cOperator % 97;
|
275
|
+
}
|
276
|
+
return cRest === 1;
|
277
|
+
}, "Please specify a valid IBAN");
|
278
|
+
|
160
279
|
jQuery.validator.addMethod("dateNL", function(value, element) {
|
161
280
|
return this.optional(element) || /^(0?[1-9]|[12]\d|3[01])[\.\/\-](0?[1-9]|1[012])[\.\/\-]([12]\d)?(\d\d)$/.test(value);
|
162
|
-
}, "
|
281
|
+
}, "Please enter a correct date");
|
282
|
+
|
283
|
+
/**
|
284
|
+
* Dutch phone numbers have 10 digits (or 11 and start with +31).
|
285
|
+
*/
|
286
|
+
jQuery.validator.addMethod("phoneNL", function(value, element) {
|
287
|
+
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);
|
288
|
+
}, "Please specify a valid phone number.");
|
289
|
+
|
290
|
+
jQuery.validator.addMethod("mobileNL", function(value, element) {
|
291
|
+
return this.optional(element) || /^((\+|00(\s|\s?\-\s?)?)31(\s|\s?\-\s?)?(\(0\)[\-\s]?)?|0)6((\s|\s?\-\s?)?[0-9]){8}$/.test(value);
|
292
|
+
}, "Please specify a valid mobile number");
|
293
|
+
|
294
|
+
jQuery.validator.addMethod("postalcodeNL", function(value, element) {
|
295
|
+
return this.optional(element) || /^[1-9][0-9]{3}\s?[a-zA-Z]{2}$/.test(value);
|
296
|
+
}, "Please specify a valid postal code");
|
297
|
+
|
298
|
+
/*
|
299
|
+
* Dutch bank account numbers (not 'giro' numbers) have 9 digits
|
300
|
+
* and pass the '11 check'.
|
301
|
+
* We accept the notation with spaces, as that is common.
|
302
|
+
* acceptable: 123456789 or 12 34 56 789
|
303
|
+
*/
|
304
|
+
jQuery.validator.addMethod("bankaccountNL", function(value, element) {
|
305
|
+
if (this.optional(element)) {
|
306
|
+
return true;
|
307
|
+
}
|
308
|
+
if (!(/^[0-9]{9}|([0-9]{2} ){3}[0-9]{3}$/.test(value))) {
|
309
|
+
return false;
|
310
|
+
}
|
311
|
+
// now '11 check'
|
312
|
+
var account = value.replace(/ /g,''); // remove spaces
|
313
|
+
var sum = 0;
|
314
|
+
var len = account.length;
|
315
|
+
for (var pos=0; pos<len; pos++) {
|
316
|
+
var factor = len - pos;
|
317
|
+
var digit = account.substring(pos, pos+1);
|
318
|
+
sum = sum + factor * digit;
|
319
|
+
}
|
320
|
+
return sum % 11 === 0;
|
321
|
+
}, "Please specify a valid bank account number");
|
322
|
+
|
323
|
+
/**
|
324
|
+
* Dutch giro account numbers (not bank numbers) have max 7 digits
|
325
|
+
*/
|
326
|
+
jQuery.validator.addMethod("giroaccountNL", function(value, element) {
|
327
|
+
return this.optional(element) || /^[0-9]{1,7}$/.test(value);
|
328
|
+
}, "Please specify a valid giro account number");
|
329
|
+
|
330
|
+
jQuery.validator.addMethod("bankorgiroaccountNL", function(value, element) {
|
331
|
+
return this.optional(element) ||
|
332
|
+
($.validator.methods["bankaccountNL"].call(this, value, element)) ||
|
333
|
+
($.validator.methods["giroaccountNL"].call(this, value, element));
|
334
|
+
}, "Please specify a valid bank or giro account number");
|
335
|
+
|
163
336
|
|
164
337
|
jQuery.validator.addMethod("time", function(value, element) {
|
165
338
|
return this.optional(element) || /^([01]\d|2[0-3])(:[0-5]\d){1,2}$/.test(value);
|
166
339
|
}, "Please enter a valid time, between 00:00 and 23:59");
|
167
340
|
jQuery.validator.addMethod("time12h", function(value, element) {
|
168
|
-
return this.optional(element) || /^((0?[1-9]|1[012])(:[0-5]\d){1,2}( ?[AP]M))$/i.test(value);
|
169
|
-
}, "Please enter a valid time in 12-hour format");
|
341
|
+
return this.optional(element) || /^((0?[1-9]|1[012])(:[0-5]\d){1,2}(\ ?[AP]M))$/i.test(value);
|
342
|
+
}, "Please enter a valid time in 12-hour am/pm format");
|
170
343
|
|
171
344
|
/**
|
172
345
|
* matches US phone number format
|
@@ -193,33 +366,33 @@ jQuery.validator.addMethod("phoneUS", function(phone_number, element) {
|
|
193
366
|
jQuery.validator.addMethod('phoneUK', function(phone_number, element) {
|
194
367
|
phone_number = phone_number.replace(/\(|\)|\s+|-/g,'');
|
195
368
|
return this.optional(element) || phone_number.length > 9 &&
|
196
|
-
phone_number.match(/^(?:(?:(?:00\s?|\+)44\s?)|(?:\(?0))(
|
369
|
+
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})$/);
|
197
370
|
}, 'Please specify a valid phone number');
|
198
371
|
|
199
372
|
jQuery.validator.addMethod('mobileUK', function(phone_number, element) {
|
200
|
-
phone_number = phone_number.replace(/\s+|-/g,'');
|
373
|
+
phone_number = phone_number.replace(/\(|\)|\s+|-/g,'');
|
201
374
|
return this.optional(element) || phone_number.length > 9 &&
|
202
375
|
phone_number.match(/^(?:(?:(?:00\s?|\+)44\s?|0)7(?:[45789]\d{2}|624)\s?\d{3}\s?\d{3})$/);
|
203
376
|
}, 'Please specify a valid mobile number');
|
204
377
|
|
205
378
|
//Matches UK landline + mobile, accepting only 01-3 for landline or 07 for mobile to exclude many premium numbers
|
206
379
|
jQuery.validator.addMethod('phonesUK', function(phone_number, element) {
|
207
|
-
phone_number = phone_number.replace(/\s+|-/g,'');
|
380
|
+
phone_number = phone_number.replace(/\(|\)|\s+|-/g,'');
|
208
381
|
return this.optional(element) || phone_number.length > 9 &&
|
209
382
|
phone_number.match(/^(?:(?:(?:00\s?|\+)44\s?|0)(?:1\d{8,9}|[23]\d{9}|7(?:[45789]\d{8}|624\d{6})))$/);
|
210
383
|
}, 'Please specify a valid uk phone number');
|
211
384
|
// On the above three UK functions, do the following server side processing:
|
212
|
-
// Compare with
|
213
|
-
//
|
214
|
-
// Extract $
|
385
|
+
// Compare original input with this RegEx pattern:
|
386
|
+
// ^\(?(?:(?:00\)?[\s\-]?\(?|\+)(44)\)?[\s\-]?\(?(?:0\)?[\s\-]?\(?)?|0)([1-9]\d{1,4}\)?[\s\d\-]+)$
|
387
|
+
// Extract $1 and set $prefix to '+44<space>' if $1 is '44', otherwise set $prefix to '0'
|
388
|
+
// Extract $2 and remove hyphens, spaces and parentheses. Phone number is combined $prefix and $2.
|
215
389
|
// A number of very detailed GB telephone number RegEx patterns can also be found at:
|
216
|
-
// http://www.aa-asterisk.org.uk/index.php/
|
390
|
+
// http://www.aa-asterisk.org.uk/index.php/Regular_Expressions_for_Validating_and_Formatting_GB_Telephone_Numbers
|
217
391
|
|
218
|
-
//Matches UK postcode.
|
219
|
-
jQuery.validator.addMethod('postcodeUK', function(
|
220
|
-
|
221
|
-
|
222
|
-
}, 'Please specify a valid postcode');
|
392
|
+
// Matches UK postcode. Does not match to UK Channel Islands that have their own postcodes (non standard UK)
|
393
|
+
jQuery.validator.addMethod('postcodeUK', function(value, element) {
|
394
|
+
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);
|
395
|
+
}, 'Please specify a valid UK postcode');
|
223
396
|
|
224
397
|
// TODO check if value starts with <, otherwise don't try stripping anything
|
225
398
|
jQuery.validator.addMethod("strippedminlength", function(value, element, param) {
|
@@ -386,9 +559,9 @@ jQuery.validator.addMethod("require_from_group", function(value, element, option
|
|
386
559
|
*
|
387
560
|
*/
|
388
561
|
jQuery.validator.addMethod("skip_or_fill_minimum", function(value, element, options) {
|
389
|
-
var validator = this
|
390
|
-
|
391
|
-
|
562
|
+
var validator = this,
|
563
|
+
numberRequired = options[0],
|
564
|
+
selector = options[1];
|
392
565
|
var numberFilled = $(selector, element.form).filter(function() {
|
393
566
|
return validator.elementValue(this);
|
394
567
|
}).length;
|
@@ -424,7 +597,7 @@ jQuery.validator.addMethod("accept", function(value, element, param) {
|
|
424
597
|
for (i = 0; i < element.files.length; i++) {
|
425
598
|
file = element.files[i];
|
426
599
|
|
427
|
-
// Grab the
|
600
|
+
// Grab the mimetype from the loaded file, verify it matches
|
428
601
|
if (!file.type.match(new RegExp( ".?(" + typeParam + ")$", "i"))) {
|
429
602
|
return false;
|
430
603
|
}
|
@@ -1,6 +1,13 @@
|
|
1
|
-
/*!
|
2
|
-
*
|
3
|
-
*
|
1
|
+
/*!
|
2
|
+
* jQuery Validation Plugin 1.11.1
|
3
|
+
*
|
4
|
+
* http://bassistance.de/jquery-plugins/jquery-plugin-validation/
|
5
|
+
* http://docs.jquery.com/Plugins/Validation
|
6
|
+
*
|
7
|
+
* Copyright 2013 Jörn Zaefferer
|
8
|
+
* Released under the MIT license:
|
9
|
+
* http://www.opensource.org/licenses/mit-license.php
|
10
|
+
*/
|
4
11
|
|
5
12
|
(function($) {
|
6
13
|
|
@@ -38,6 +45,11 @@ $.extend($.fn, {
|
|
38
45
|
if ( $(event.target).hasClass("cancel") ) {
|
39
46
|
validator.cancelSubmit = true;
|
40
47
|
}
|
48
|
+
|
49
|
+
// allow suppressing validation by adding the html5 formnovalidate attribute to the submit button
|
50
|
+
if ( $(event.target).attr("formnovalidate") !== undefined ) {
|
51
|
+
validator.cancelSubmit = true;
|
52
|
+
}
|
41
53
|
});
|
42
54
|
|
43
55
|
// validate the form on submit
|
@@ -51,7 +63,7 @@ $.extend($.fn, {
|
|
51
63
|
if ( validator.settings.submitHandler ) {
|
52
64
|
if ( validator.submitButton ) {
|
53
65
|
// insert a hidden input as a replacement for the missing submit button
|
54
|
-
hidden = $("<input type='hidden'/>").attr("name", validator.submitButton.name).val(validator.submitButton.
|
66
|
+
hidden = $("<input type='hidden'/>").attr("name", validator.submitButton.name).val( $(validator.submitButton).val() ).appendTo(validator.currentForm);
|
55
67
|
}
|
56
68
|
validator.settings.submitHandler.call( validator, validator.currentForm, event );
|
57
69
|
if ( validator.submitButton ) {
|
@@ -91,7 +103,7 @@ $.extend($.fn, {
|
|
91
103
|
var valid = true;
|
92
104
|
var validator = $(this[0].form).validate();
|
93
105
|
this.each(function() {
|
94
|
-
valid
|
106
|
+
valid = valid && validator.element(this);
|
95
107
|
});
|
96
108
|
return valid;
|
97
109
|
}
|
@@ -117,6 +129,8 @@ $.extend($.fn, {
|
|
117
129
|
switch(command) {
|
118
130
|
case "add":
|
119
131
|
$.extend(existingRules, $.validator.normalizeRule(argument));
|
132
|
+
// remove messages from rules, but allow them to be set separetely
|
133
|
+
delete existingRules.messages;
|
120
134
|
staticRules[element.name] = existingRules;
|
121
135
|
if ( argument.messages ) {
|
122
136
|
settings.messages[element.name] = $.extend( settings.messages[element.name], argument.messages );
|
@@ -159,11 +173,11 @@ $.extend($.fn, {
|
|
159
173
|
// Custom selectors
|
160
174
|
$.extend($.expr[":"], {
|
161
175
|
// http://docs.jquery.com/Plugins/Validation/blank
|
162
|
-
blank: function( a ) { return !$.trim("" + a.
|
176
|
+
blank: function( a ) { return !$.trim("" + $(a).val()); },
|
163
177
|
// http://docs.jquery.com/Plugins/Validation/filled
|
164
|
-
filled: function( a ) { return !!$.trim("" + a.
|
178
|
+
filled: function( a ) { return !!$.trim("" + $(a).val()); },
|
165
179
|
// http://docs.jquery.com/Plugins/Validation/unchecked
|
166
|
-
unchecked: function( a ) { return
|
180
|
+
unchecked: function( a ) { return !$(a).prop("checked"); }
|
167
181
|
});
|
168
182
|
|
169
183
|
// constructor for validator
|
@@ -553,7 +567,7 @@ $.extend($.validator, {
|
|
553
567
|
}
|
554
568
|
} catch(e) {
|
555
569
|
if ( this.settings.debug && window.console ) {
|
556
|
-
console.log( "Exception
|
570
|
+
console.log( "Exception occurred when checking element " + element.id + ", check the '" + rule.method + "' method.", e );
|
557
571
|
}
|
558
572
|
throw e;
|
559
573
|
}
|
@@ -826,6 +840,7 @@ $.extend($.validator, {
|
|
826
840
|
attributeRules: function( element ) {
|
827
841
|
var rules = {};
|
828
842
|
var $element = $(element);
|
843
|
+
var type = $element[0].getAttribute("type");
|
829
844
|
|
830
845
|
for (var method in $.validator.methods) {
|
831
846
|
var value;
|
@@ -844,9 +859,17 @@ $.extend($.validator, {
|
|
844
859
|
value = $element.attr(method);
|
845
860
|
}
|
846
861
|
|
862
|
+
// convert the value to a number for number inputs, and for text for backwards compability
|
863
|
+
// allows type="date" and others to be compared as strings
|
864
|
+
if ( /min|max/.test( method ) && ( type === null || /number|range|text/.test( type ) ) ) {
|
865
|
+
value = Number(value);
|
866
|
+
}
|
867
|
+
|
847
868
|
if ( value ) {
|
848
869
|
rules[method] = value;
|
849
|
-
} else if (
|
870
|
+
} else if ( type === method && type !== 'range' ) {
|
871
|
+
// exception: the jquery validate 'range' method
|
872
|
+
// does not test for the html5 'range' type
|
850
873
|
rules[method] = true;
|
851
874
|
}
|
852
875
|
}
|
@@ -917,7 +940,7 @@ $.extend($.validator, {
|
|
917
940
|
rules[this] = Number(rules[this]);
|
918
941
|
}
|
919
942
|
});
|
920
|
-
$.each(['rangelength'], function() {
|
943
|
+
$.each(['rangelength', 'range'], function() {
|
921
944
|
var parts;
|
922
945
|
if ( rules[this] ) {
|
923
946
|
if ( $.isArray(rules[this]) ) {
|
@@ -986,93 +1009,6 @@ $.extend($.validator, {
|
|
986
1009
|
return $.trim(value).length > 0;
|
987
1010
|
},
|
988
1011
|
|
989
|
-
// http://docs.jquery.com/Plugins/Validation/Methods/remote
|
990
|
-
remote: function( value, element, param ) {
|
991
|
-
if ( this.optional(element) ) {
|
992
|
-
return "dependency-mismatch";
|
993
|
-
}
|
994
|
-
|
995
|
-
var previous = this.previousValue(element);
|
996
|
-
if (!this.settings.messages[element.name] ) {
|
997
|
-
this.settings.messages[element.name] = {};
|
998
|
-
}
|
999
|
-
previous.originalMessage = this.settings.messages[element.name].remote;
|
1000
|
-
this.settings.messages[element.name].remote = previous.message;
|
1001
|
-
|
1002
|
-
param = typeof param === "string" && {url:param} || param;
|
1003
|
-
|
1004
|
-
if ( previous.old === value ) {
|
1005
|
-
return previous.valid;
|
1006
|
-
}
|
1007
|
-
|
1008
|
-
previous.old = value;
|
1009
|
-
var validator = this;
|
1010
|
-
this.startRequest(element);
|
1011
|
-
var data = {};
|
1012
|
-
data[element.name] = value;
|
1013
|
-
$.ajax($.extend(true, {
|
1014
|
-
url: param,
|
1015
|
-
mode: "abort",
|
1016
|
-
port: "validate" + element.name,
|
1017
|
-
dataType: "json",
|
1018
|
-
data: data,
|
1019
|
-
success: function( response ) {
|
1020
|
-
validator.settings.messages[element.name].remote = previous.originalMessage;
|
1021
|
-
var valid = response === true || response === "true";
|
1022
|
-
if ( valid ) {
|
1023
|
-
var submitted = validator.formSubmitted;
|
1024
|
-
validator.prepareElement(element);
|
1025
|
-
validator.formSubmitted = submitted;
|
1026
|
-
validator.successList.push(element);
|
1027
|
-
delete validator.invalid[element.name];
|
1028
|
-
validator.showErrors();
|
1029
|
-
} else {
|
1030
|
-
var errors = {};
|
1031
|
-
var message = response || validator.defaultMessage( element, "remote" );
|
1032
|
-
errors[element.name] = previous.message = $.isFunction(message) ? message(value) : message;
|
1033
|
-
validator.invalid[element.name] = true;
|
1034
|
-
validator.showErrors(errors);
|
1035
|
-
}
|
1036
|
-
previous.valid = valid;
|
1037
|
-
validator.stopRequest(element, valid);
|
1038
|
-
}
|
1039
|
-
}, param));
|
1040
|
-
return "pending";
|
1041
|
-
},
|
1042
|
-
|
1043
|
-
// http://docs.jquery.com/Plugins/Validation/Methods/minlength
|
1044
|
-
minlength: function( value, element, param ) {
|
1045
|
-
var length = $.isArray( value ) ? value.length : this.getLength($.trim(value), element);
|
1046
|
-
return this.optional(element) || length >= param;
|
1047
|
-
},
|
1048
|
-
|
1049
|
-
// http://docs.jquery.com/Plugins/Validation/Methods/maxlength
|
1050
|
-
maxlength: function( value, element, param ) {
|
1051
|
-
var length = $.isArray( value ) ? value.length : this.getLength($.trim(value), element);
|
1052
|
-
return this.optional(element) || length <= param;
|
1053
|
-
},
|
1054
|
-
|
1055
|
-
// http://docs.jquery.com/Plugins/Validation/Methods/rangelength
|
1056
|
-
rangelength: function( value, element, param ) {
|
1057
|
-
var length = $.isArray( value ) ? value.length : this.getLength($.trim(value), element);
|
1058
|
-
return this.optional(element) || ( length >= param[0] && length <= param[1] );
|
1059
|
-
},
|
1060
|
-
|
1061
|
-
// http://docs.jquery.com/Plugins/Validation/Methods/min
|
1062
|
-
min: function( value, element, param ) {
|
1063
|
-
return this.optional(element) || value >= param;
|
1064
|
-
},
|
1065
|
-
|
1066
|
-
// http://docs.jquery.com/Plugins/Validation/Methods/max
|
1067
|
-
max: function( value, element, param ) {
|
1068
|
-
return this.optional(element) || value <= param;
|
1069
|
-
},
|
1070
|
-
|
1071
|
-
// http://docs.jquery.com/Plugins/Validation/Methods/range
|
1072
|
-
range: function( value, element, param ) {
|
1073
|
-
return this.optional(element) || ( value >= param[0] && value <= param[1] );
|
1074
|
-
},
|
1075
|
-
|
1076
1012
|
// http://docs.jquery.com/Plugins/Validation/Methods/email
|
1077
1013
|
email: function( value, element ) {
|
1078
1014
|
// contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/
|
@@ -1136,6 +1072,39 @@ $.extend($.validator, {
|
|
1136
1072
|
return (nCheck % 10) === 0;
|
1137
1073
|
},
|
1138
1074
|
|
1075
|
+
// http://docs.jquery.com/Plugins/Validation/Methods/minlength
|
1076
|
+
minlength: function( value, element, param ) {
|
1077
|
+
var length = $.isArray( value ) ? value.length : this.getLength($.trim(value), element);
|
1078
|
+
return this.optional(element) || length >= param;
|
1079
|
+
},
|
1080
|
+
|
1081
|
+
// http://docs.jquery.com/Plugins/Validation/Methods/maxlength
|
1082
|
+
maxlength: function( value, element, param ) {
|
1083
|
+
var length = $.isArray( value ) ? value.length : this.getLength($.trim(value), element);
|
1084
|
+
return this.optional(element) || length <= param;
|
1085
|
+
},
|
1086
|
+
|
1087
|
+
// http://docs.jquery.com/Plugins/Validation/Methods/rangelength
|
1088
|
+
rangelength: function( value, element, param ) {
|
1089
|
+
var length = $.isArray( value ) ? value.length : this.getLength($.trim(value), element);
|
1090
|
+
return this.optional(element) || ( length >= param[0] && length <= param[1] );
|
1091
|
+
},
|
1092
|
+
|
1093
|
+
// http://docs.jquery.com/Plugins/Validation/Methods/min
|
1094
|
+
min: function( value, element, param ) {
|
1095
|
+
return this.optional(element) || value >= param;
|
1096
|
+
},
|
1097
|
+
|
1098
|
+
// http://docs.jquery.com/Plugins/Validation/Methods/max
|
1099
|
+
max: function( value, element, param ) {
|
1100
|
+
return this.optional(element) || value <= param;
|
1101
|
+
},
|
1102
|
+
|
1103
|
+
// http://docs.jquery.com/Plugins/Validation/Methods/range
|
1104
|
+
range: function( value, element, param ) {
|
1105
|
+
return this.optional(element) || ( value >= param[0] && value <= param[1] );
|
1106
|
+
},
|
1107
|
+
|
1139
1108
|
// http://docs.jquery.com/Plugins/Validation/Methods/equalTo
|
1140
1109
|
equalTo: function( value, element, param ) {
|
1141
1110
|
// bind to the blur event of the target in order to revalidate whenever the target field is updated
|
@@ -1147,6 +1116,60 @@ $.extend($.validator, {
|
|
1147
1116
|
});
|
1148
1117
|
}
|
1149
1118
|
return value === target.val();
|
1119
|
+
},
|
1120
|
+
|
1121
|
+
// http://docs.jquery.com/Plugins/Validation/Methods/remote
|
1122
|
+
remote: function( value, element, param ) {
|
1123
|
+
if ( this.optional(element) ) {
|
1124
|
+
return "dependency-mismatch";
|
1125
|
+
}
|
1126
|
+
|
1127
|
+
var previous = this.previousValue(element);
|
1128
|
+
if (!this.settings.messages[element.name] ) {
|
1129
|
+
this.settings.messages[element.name] = {};
|
1130
|
+
}
|
1131
|
+
previous.originalMessage = this.settings.messages[element.name].remote;
|
1132
|
+
this.settings.messages[element.name].remote = previous.message;
|
1133
|
+
|
1134
|
+
param = typeof param === "string" && {url:param} || param;
|
1135
|
+
|
1136
|
+
if ( previous.old === value ) {
|
1137
|
+
return previous.valid;
|
1138
|
+
}
|
1139
|
+
|
1140
|
+
previous.old = value;
|
1141
|
+
var validator = this;
|
1142
|
+
this.startRequest(element);
|
1143
|
+
var data = {};
|
1144
|
+
data[element.name] = value;
|
1145
|
+
$.ajax($.extend(true, {
|
1146
|
+
url: param,
|
1147
|
+
mode: "abort",
|
1148
|
+
port: "validate" + element.name,
|
1149
|
+
dataType: "json",
|
1150
|
+
data: data,
|
1151
|
+
success: function( response ) {
|
1152
|
+
validator.settings.messages[element.name].remote = previous.originalMessage;
|
1153
|
+
var valid = response === true || response === "true";
|
1154
|
+
if ( valid ) {
|
1155
|
+
var submitted = validator.formSubmitted;
|
1156
|
+
validator.prepareElement(element);
|
1157
|
+
validator.formSubmitted = submitted;
|
1158
|
+
validator.successList.push(element);
|
1159
|
+
delete validator.invalid[element.name];
|
1160
|
+
validator.showErrors();
|
1161
|
+
} else {
|
1162
|
+
var errors = {};
|
1163
|
+
var message = response || validator.defaultMessage( element, "remote" );
|
1164
|
+
errors[element.name] = previous.message = $.isFunction(message) ? message(value) : message;
|
1165
|
+
validator.invalid[element.name] = true;
|
1166
|
+
validator.showErrors(errors);
|
1167
|
+
}
|
1168
|
+
previous.valid = valid;
|
1169
|
+
validator.stopRequest(element, valid);
|
1170
|
+
}
|
1171
|
+
}, param));
|
1172
|
+
return "pending";
|
1150
1173
|
}
|
1151
1174
|
|
1152
1175
|
}
|
@@ -1184,7 +1207,8 @@ $.format = $.validator.format;
|
|
1184
1207
|
if ( pendingRequests[port] ) {
|
1185
1208
|
pendingRequests[port].abort();
|
1186
1209
|
}
|
1187
|
-
|
1210
|
+
pendingRequests[port] = ajax.apply(this, arguments);
|
1211
|
+
return pendingRequests[port];
|
1188
1212
|
}
|
1189
1213
|
return ajax.apply(this, arguments);
|
1190
1214
|
};
|