jquery-validation-rails 1.12.0 → 1.13.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +4 -0
  3. data/app/assets/javascripts/jquery.validate.additional-methods.js +181 -74
  4. data/app/assets/javascripts/jquery.validate.js +407 -335
  5. data/app/assets/javascripts/jquery.validate.localization/messages_ar.js +29 -21
  6. data/app/assets/javascripts/jquery.validate.localization/messages_bg.js +29 -21
  7. data/app/assets/javascripts/jquery.validate.localization/messages_ca.js +29 -21
  8. data/app/assets/javascripts/jquery.validate.localization/messages_cs.js +29 -21
  9. data/app/assets/javascripts/jquery.validate.localization/messages_da.js +26 -18
  10. data/app/assets/javascripts/jquery.validate.localization/messages_de.js +26 -18
  11. data/app/assets/javascripts/jquery.validate.localization/messages_el.js +29 -21
  12. data/app/assets/javascripts/jquery.validate.localization/messages_es.js +32 -24
  13. data/app/assets/javascripts/jquery.validate.localization/messages_es_AR.js +32 -24
  14. data/app/assets/javascripts/jquery.validate.localization/messages_et.js +27 -19
  15. data/app/assets/javascripts/jquery.validate.localization/messages_eu.js +29 -21
  16. data/app/assets/javascripts/jquery.validate.localization/messages_fa.js +32 -21
  17. data/app/assets/javascripts/jquery.validate.localization/messages_fi.js +27 -19
  18. data/app/assets/javascripts/jquery.validate.localization/messages_fr.js +55 -46
  19. data/app/assets/javascripts/jquery.validate.localization/messages_gl.js +38 -0
  20. data/app/assets/javascripts/jquery.validate.localization/messages_he.js +29 -21
  21. data/app/assets/javascripts/jquery.validate.localization/messages_hr.js +29 -21
  22. data/app/assets/javascripts/jquery.validate.localization/messages_hu.js +28 -20
  23. data/app/assets/javascripts/jquery.validate.localization/messages_id.js +28 -20
  24. data/app/assets/javascripts/jquery.validate.localization/messages_is.js +27 -19
  25. data/app/assets/javascripts/jquery.validate.localization/messages_it.js +32 -24
  26. data/app/assets/javascripts/jquery.validate.localization/messages_ja.js +29 -21
  27. data/app/assets/javascripts/jquery.validate.localization/messages_ka.js +29 -21
  28. data/app/assets/javascripts/jquery.validate.localization/messages_kk.js +29 -21
  29. data/app/assets/javascripts/jquery.validate.localization/messages_ko.js +29 -21
  30. data/app/assets/javascripts/jquery.validate.localization/messages_lt.js +29 -21
  31. data/app/assets/javascripts/jquery.validate.localization/messages_lv.js +29 -21
  32. data/app/assets/javascripts/jquery.validate.localization/messages_my.js +29 -21
  33. data/app/assets/javascripts/jquery.validate.localization/messages_nl.js +38 -30
  34. data/app/assets/javascripts/jquery.validate.localization/messages_no.js +29 -21
  35. data/app/assets/javascripts/jquery.validate.localization/messages_pl.js +29 -21
  36. data/app/assets/javascripts/jquery.validate.localization/messages_pt_BR.js +33 -24
  37. data/app/assets/javascripts/jquery.validate.localization/messages_pt_PT.js +32 -24
  38. data/app/assets/javascripts/jquery.validate.localization/messages_ro.js +29 -21
  39. data/app/assets/javascripts/jquery.validate.localization/messages_ru.js +29 -21
  40. data/app/assets/javascripts/jquery.validate.localization/messages_si.js +29 -21
  41. data/app/assets/javascripts/jquery.validate.localization/messages_sk.js +26 -18
  42. data/app/assets/javascripts/jquery.validate.localization/messages_sl.js +29 -21
  43. data/app/assets/javascripts/jquery.validate.localization/messages_sr.js +29 -21
  44. data/app/assets/javascripts/jquery.validate.localization/messages_sr_lat.js +29 -21
  45. data/app/assets/javascripts/jquery.validate.localization/messages_sv.js +27 -19
  46. data/app/assets/javascripts/jquery.validate.localization/messages_th.js +29 -21
  47. data/app/assets/javascripts/jquery.validate.localization/messages_tj.js +29 -21
  48. data/app/assets/javascripts/jquery.validate.localization/messages_tr.js +29 -21
  49. data/app/assets/javascripts/jquery.validate.localization/messages_uk.js +29 -21
  50. data/app/assets/javascripts/jquery.validate.localization/messages_vi.js +29 -21
  51. data/app/assets/javascripts/jquery.validate.localization/messages_zh.js +29 -21
  52. data/app/assets/javascripts/jquery.validate.localization/messages_zh_TW.js +29 -21
  53. data/app/assets/javascripts/jquery.validate.localization/methods_de.js +11 -1
  54. data/app/assets/javascripts/jquery.validate.localization/methods_es_CL.js +11 -1
  55. data/app/assets/javascripts/jquery.validate.localization/methods_fi.js +22 -0
  56. data/app/assets/javascripts/jquery.validate.localization/methods_nl.js +11 -1
  57. data/app/assets/javascripts/jquery.validate.localization/methods_pt.js +11 -1
  58. data/lib/jquery/validation/rails/version.rb +1 -1
  59. metadata +4 -2
@@ -1,12 +1,18 @@
1
1
  /*!
2
- * jQuery Validation Plugin v1.12.0
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($) {
9
+ (function( factory ) {
10
+ if ( typeof define === "function" && define.amd ) {
11
+ define( ["jquery"], factory );
12
+ } else {
13
+ factory( jQuery );
14
+ }
15
+ }(function( $ ) {
10
16
 
11
17
  $.extend($.fn, {
12
18
  // http://jqueryvalidation.org/validate/
@@ -21,7 +27,7 @@ $.extend($.fn, {
21
27
  }
22
28
 
23
29
  // check if a validator for this form was already created
24
- var validator = $.data( this[0], "validator" );
30
+ var validator = $.data( this[ 0 ], "validator" );
25
31
  if ( validator ) {
26
32
  return validator;
27
33
  }
@@ -29,8 +35,8 @@ $.extend($.fn, {
29
35
  // Add novalidate tag if HTML5.
30
36
  this.attr( "novalidate", "novalidate" );
31
37
 
32
- validator = new $.validator( options, this[0] );
33
- $.data( this[0], "validator", validator );
38
+ validator = new $.validator( options, this[ 0 ] );
39
+ $.data( this[ 0 ], "validator", validator );
34
40
 
35
41
  if ( validator.settings.onsubmit ) {
36
42
 
@@ -39,12 +45,12 @@ $.extend($.fn, {
39
45
  validator.submitButton = event.target;
40
46
  }
41
47
  // allow suppressing validation by adding a cancel class to the submit button
42
- if ( $(event.target).hasClass("cancel") ) {
48
+ if ( $( event.target ).hasClass( "cancel" ) ) {
43
49
  validator.cancelSubmit = true;
44
50
  }
45
51
 
46
52
  // allow suppressing validation by adding the html5 formnovalidate attribute to the submit button
47
- if ( $(event.target).attr("formnovalidate") !== undefined ) {
53
+ if ( $( event.target ).attr( "formnovalidate" ) !== undefined ) {
48
54
  validator.cancelSubmit = true;
49
55
  }
50
56
  });
@@ -56,17 +62,23 @@ $.extend($.fn, {
56
62
  event.preventDefault();
57
63
  }
58
64
  function handle() {
59
- var hidden;
65
+ var hidden, result;
60
66
  if ( validator.settings.submitHandler ) {
61
67
  if ( validator.submitButton ) {
62
68
  // insert a hidden input as a replacement for the missing submit button
63
- hidden = $("<input type='hidden'/>").attr("name", validator.submitButton.name).val( $(validator.submitButton).val() ).appendTo(validator.currentForm);
69
+ hidden = $( "<input type='hidden'/>" )
70
+ .attr( "name", validator.submitButton.name )
71
+ .val( $( validator.submitButton ).val() )
72
+ .appendTo( validator.currentForm );
64
73
  }
65
- validator.settings.submitHandler.call( validator, validator.currentForm, event );
74
+ result = validator.settings.submitHandler.call( validator, validator.currentForm, event );
66
75
  if ( validator.submitButton ) {
67
76
  // and clean up afterwards; thanks to no-block-scope, hidden can be referenced
68
77
  hidden.remove();
69
78
  }
79
+ if ( result !== undefined ) {
80
+ return result;
81
+ }
70
82
  return false;
71
83
  }
72
84
  return true;
@@ -96,13 +108,13 @@ $.extend($.fn, {
96
108
  valid: function() {
97
109
  var valid, validator;
98
110
 
99
- if ( $(this[0]).is("form")) {
111
+ if ( $( this[ 0 ] ).is( "form" ) ) {
100
112
  valid = this.validate().form();
101
113
  } else {
102
114
  valid = true;
103
- validator = $(this[0].form).validate();
104
- this.each(function() {
105
- valid = validator.element(this) && valid;
115
+ validator = $( this[ 0 ].form ).validate();
116
+ this.each( function() {
117
+ valid = validator.element( this ) && valid;
106
118
  });
107
119
  }
108
120
  return valid;
@@ -111,42 +123,42 @@ $.extend($.fn, {
111
123
  removeAttrs: function( attributes ) {
112
124
  var result = {},
113
125
  $element = this;
114
- $.each(attributes.split(/\s/), function( index, value ) {
115
- result[value] = $element.attr(value);
116
- $element.removeAttr(value);
126
+ $.each( attributes.split( /\s/ ), function( index, value ) {
127
+ result[ value ] = $element.attr( value );
128
+ $element.removeAttr( value );
117
129
  });
118
130
  return result;
119
131
  },
120
132
  // http://jqueryvalidation.org/rules/
121
133
  rules: function( command, argument ) {
122
- var element = this[0],
134
+ var element = this[ 0 ],
123
135
  settings, staticRules, existingRules, data, param, filtered;
124
136
 
125
137
  if ( command ) {
126
- settings = $.data(element.form, "validator").settings;
138
+ settings = $.data( element.form, "validator" ).settings;
127
139
  staticRules = settings.rules;
128
- existingRules = $.validator.staticRules(element);
129
- switch (command) {
140
+ existingRules = $.validator.staticRules( element );
141
+ switch ( command ) {
130
142
  case "add":
131
- $.extend(existingRules, $.validator.normalizeRule(argument));
143
+ $.extend( existingRules, $.validator.normalizeRule( argument ) );
132
144
  // remove messages from rules, but allow them to be set separately
133
145
  delete existingRules.messages;
134
- staticRules[element.name] = existingRules;
146
+ staticRules[ element.name ] = existingRules;
135
147
  if ( argument.messages ) {
136
- settings.messages[element.name] = $.extend( settings.messages[element.name], argument.messages );
148
+ settings.messages[ element.name ] = $.extend( settings.messages[ element.name ], argument.messages );
137
149
  }
138
150
  break;
139
151
  case "remove":
140
152
  if ( !argument ) {
141
- delete staticRules[element.name];
153
+ delete staticRules[ element.name ];
142
154
  return existingRules;
143
155
  }
144
156
  filtered = {};
145
- $.each(argument.split(/\s/), function( index, method ) {
146
- filtered[method] = existingRules[method];
147
- delete existingRules[method];
157
+ $.each( argument.split( /\s/ ), function( index, method ) {
158
+ filtered[ method ] = existingRules[ method ];
159
+ delete existingRules[ method ];
148
160
  if ( method === "required" ) {
149
- $(element).removeAttr("aria-required");
161
+ $( element ).removeAttr( "aria-required" );
150
162
  }
151
163
  });
152
164
  return filtered;
@@ -156,18 +168,18 @@ $.extend($.fn, {
156
168
  data = $.validator.normalizeRules(
157
169
  $.extend(
158
170
  {},
159
- $.validator.classRules(element),
160
- $.validator.attributeRules(element),
161
- $.validator.dataRules(element),
162
- $.validator.staticRules(element)
163
- ), element);
171
+ $.validator.classRules( element ),
172
+ $.validator.attributeRules( element ),
173
+ $.validator.dataRules( element ),
174
+ $.validator.staticRules( element )
175
+ ), element );
164
176
 
165
177
  // make sure required is at front
166
178
  if ( data.required ) {
167
179
  param = data.required;
168
180
  delete data.required;
169
- data = $.extend({ required: param }, data );
170
- $(element).attr( "aria-required", "true" );
181
+ data = $.extend( { required: param }, data );
182
+ $( element ).attr( "aria-required", "true" );
171
183
  }
172
184
 
173
185
  // make sure remote is at back
@@ -182,13 +194,19 @@ $.extend($.fn, {
182
194
  });
183
195
 
184
196
  // Custom selectors
185
- $.extend($.expr[":"], {
197
+ $.extend( $.expr[ ":" ], {
186
198
  // http://jqueryvalidation.org/blank-selector/
187
- blank: function( a ) { return !$.trim("" + $(a).val()); },
199
+ blank: function( a ) {
200
+ return !$.trim( "" + $( a ).val() );
201
+ },
188
202
  // http://jqueryvalidation.org/filled-selector/
189
- filled: function( a ) { return !!$.trim("" + $(a).val()); },
203
+ filled: function( a ) {
204
+ return !!$.trim( "" + $( a ).val() );
205
+ },
190
206
  // http://jqueryvalidation.org/unchecked-selector/
191
- unchecked: function( a ) { return !$(a).prop("checked"); }
207
+ unchecked: function( a ) {
208
+ return !$( a ).prop( "checked" );
209
+ }
192
210
  });
193
211
 
194
212
  // constructor for validator
@@ -202,26 +220,26 @@ $.validator = function( options, form ) {
202
220
  $.validator.format = function( source, params ) {
203
221
  if ( arguments.length === 1 ) {
204
222
  return function() {
205
- var args = $.makeArray(arguments);
206
- args.unshift(source);
223
+ var args = $.makeArray( arguments );
224
+ args.unshift( source );
207
225
  return $.validator.format.apply( this, args );
208
226
  };
209
227
  }
210
228
  if ( arguments.length > 2 && params.constructor !== Array ) {
211
- params = $.makeArray(arguments).slice(1);
229
+ params = $.makeArray( arguments ).slice( 1 );
212
230
  }
213
231
  if ( params.constructor !== Array ) {
214
232
  params = [ params ];
215
233
  }
216
- $.each(params, function( i, n ) {
217
- source = source.replace( new RegExp("\\{" + i + "\\}", "g"), function() {
234
+ $.each( params, function( i, n ) {
235
+ source = source.replace( new RegExp( "\\{" + i + "\\}", "g" ), function() {
218
236
  return n;
219
237
  });
220
238
  });
221
239
  return source;
222
240
  };
223
241
 
224
- $.extend($.validator, {
242
+ $.extend( $.validator, {
225
243
 
226
244
  defaults: {
227
245
  messages: {},
@@ -230,57 +248,58 @@ $.extend($.validator, {
230
248
  errorClass: "error",
231
249
  validClass: "valid",
232
250
  errorElement: "label",
251
+ focusCleanup: false,
233
252
  focusInvalid: true,
234
- errorContainer: $([]),
235
- errorLabelContainer: $([]),
253
+ errorContainer: $( [] ),
254
+ errorLabelContainer: $( [] ),
236
255
  onsubmit: true,
237
256
  ignore: ":hidden",
238
257
  ignoreTitle: false,
239
258
  onfocusin: function( element ) {
240
259
  this.lastActive = element;
241
260
 
242
- // hide error label and remove error class on focus if enabled
243
- if ( this.settings.focusCleanup && !this.blockFocusCleanup ) {
261
+ // Hide error label and remove error class on focus if enabled
262
+ if ( this.settings.focusCleanup ) {
244
263
  if ( this.settings.unhighlight ) {
245
264
  this.settings.unhighlight.call( this, element, this.settings.errorClass, this.settings.validClass );
246
265
  }
247
- this.addWrapper(this.errorsFor(element)).hide();
266
+ this.hideThese( this.errorsFor( element ) );
248
267
  }
249
268
  },
250
269
  onfocusout: function( element ) {
251
- if ( !this.checkable(element) && (element.name in this.submitted || !this.optional(element)) ) {
252
- this.element(element);
270
+ if ( !this.checkable( element ) && ( element.name in this.submitted || !this.optional( element ) ) ) {
271
+ this.element( element );
253
272
  }
254
273
  },
255
274
  onkeyup: function( element, event ) {
256
- if ( event.which === 9 && this.elementValue(element) === "" ) {
275
+ if ( event.which === 9 && this.elementValue( element ) === "" ) {
257
276
  return;
258
277
  } else if ( element.name in this.submitted || element === this.lastElement ) {
259
- this.element(element);
278
+ this.element( element );
260
279
  }
261
280
  },
262
281
  onclick: function( element ) {
263
282
  // click on selects, radiobuttons and checkboxes
264
283
  if ( element.name in this.submitted ) {
265
- this.element(element);
284
+ this.element( element );
266
285
 
267
286
  // or option elements, check parent select in that case
268
287
  } else if ( element.parentNode.name in this.submitted ) {
269
- this.element(element.parentNode);
288
+ this.element( element.parentNode );
270
289
  }
271
290
  },
272
291
  highlight: function( element, errorClass, validClass ) {
273
292
  if ( element.type === "radio" ) {
274
- this.findByName(element.name).addClass(errorClass).removeClass(validClass);
293
+ this.findByName( element.name ).addClass( errorClass ).removeClass( validClass );
275
294
  } else {
276
- $(element).addClass(errorClass).removeClass(validClass);
295
+ $( element ).addClass( errorClass ).removeClass( validClass );
277
296
  }
278
297
  },
279
298
  unhighlight: function( element, errorClass, validClass ) {
280
299
  if ( element.type === "radio" ) {
281
- this.findByName(element.name).removeClass(errorClass).addClass(validClass);
300
+ this.findByName( element.name ).removeClass( errorClass ).addClass( validClass );
282
301
  } else {
283
- $(element).removeClass(errorClass).addClass(validClass);
302
+ $( element ).removeClass( errorClass ).addClass( validClass );
284
303
  }
285
304
  }
286
305
  },
@@ -296,17 +315,17 @@ $.extend($.validator, {
296
315
  email: "Please enter a valid email address.",
297
316
  url: "Please enter a valid URL.",
298
317
  date: "Please enter a valid date.",
299
- dateISO: "Please enter a valid date (ISO).",
318
+ dateISO: "Please enter a valid date ( ISO ).",
300
319
  number: "Please enter a valid number.",
301
320
  digits: "Please enter only digits.",
302
321
  creditcard: "Please enter a valid credit card number.",
303
322
  equalTo: "Please enter the same value again.",
304
- maxlength: $.validator.format("Please enter no more than {0} characters."),
305
- minlength: $.validator.format("Please enter at least {0} characters."),
306
- rangelength: $.validator.format("Please enter a value between {0} and {1} characters long."),
307
- range: $.validator.format("Please enter a value between {0} and {1}."),
308
- max: $.validator.format("Please enter a value less than or equal to {0}."),
309
- min: $.validator.format("Please enter a value greater than or equal to {0}.")
323
+ maxlength: $.validator.format( "Please enter no more than {0} characters." ),
324
+ minlength: $.validator.format( "Please enter at least {0} characters." ),
325
+ rangelength: $.validator.format( "Please enter a value between {0} and {1} characters long." ),
326
+ range: $.validator.format( "Please enter a value between {0} and {1}." ),
327
+ max: $.validator.format( "Please enter a value less than or equal to {0}." ),
328
+ min: $.validator.format( "Please enter a value greater than or equal to {0}." )
310
329
  },
311
330
 
312
331
  autoCreateRanges: false,
@@ -314,9 +333,9 @@ $.extend($.validator, {
314
333
  prototype: {
315
334
 
316
335
  init: function() {
317
- this.labelContainer = $(this.settings.errorLabelContainer);
318
- this.errorContext = this.labelContainer.length && this.labelContainer || $(this.currentForm);
319
- this.containers = $(this.settings.errorContainer).add( this.settings.errorLabelContainer );
336
+ this.labelContainer = $( this.settings.errorLabelContainer );
337
+ this.errorContext = this.labelContainer.length && this.labelContainer || $( this.currentForm );
338
+ this.containers = $( this.settings.errorContainer ).add( this.settings.errorLabelContainer );
320
339
  this.submitted = {};
321
340
  this.valueCache = {};
322
341
  this.pendingRequest = 0;
@@ -324,54 +343,56 @@ $.extend($.validator, {
324
343
  this.invalid = {};
325
344
  this.reset();
326
345
 
327
- var groups = (this.groups = {}),
346
+ var groups = ( this.groups = {} ),
328
347
  rules;
329
- $.each(this.settings.groups, function( key, value ) {
348
+ $.each( this.settings.groups, function( key, value ) {
330
349
  if ( typeof value === "string" ) {
331
- value = value.split(/\s/);
350
+ value = value.split( /\s/ );
332
351
  }
333
- $.each(value, function( index, name ) {
334
- groups[name] = key;
352
+ $.each( value, function( index, name ) {
353
+ groups[ name ] = key;
335
354
  });
336
355
  });
337
356
  rules = this.settings.rules;
338
- $.each(rules, function( key, value ) {
339
- rules[key] = $.validator.normalizeRule(value);
357
+ $.each( rules, function( key, value ) {
358
+ rules[ key ] = $.validator.normalizeRule( value );
340
359
  });
341
360
 
342
- function delegate(event) {
343
- var validator = $.data(this[0].form, "validator"),
344
- eventType = "on" + event.type.replace(/^validate/, ""),
361
+ function delegate( event ) {
362
+ var validator = $.data( this[ 0 ].form, "validator" ),
363
+ eventType = "on" + event.type.replace( /^validate/, "" ),
345
364
  settings = validator.settings;
346
- if ( settings[eventType] && !this.is( settings.ignore ) ) {
347
- settings[eventType].call(validator, this[0], event);
365
+ if ( settings[ eventType ] && !this.is( settings.ignore ) ) {
366
+ settings[ eventType ].call( validator, this[ 0 ], event );
348
367
  }
349
368
  }
350
- $(this.currentForm)
351
- .validateDelegate(":text, [type='password'], [type='file'], select, textarea, " +
369
+ $( this.currentForm )
370
+ .validateDelegate( ":text, [type='password'], [type='file'], select, textarea, " +
352
371
  "[type='number'], [type='search'] ,[type='tel'], [type='url'], " +
353
372
  "[type='email'], [type='datetime'], [type='date'], [type='month'], " +
354
373
  "[type='week'], [type='time'], [type='datetime-local'], " +
355
- "[type='range'], [type='color'] ",
374
+ "[type='range'], [type='color'], [type='radio'], [type='checkbox']",
356
375
  "focusin focusout keyup", delegate)
357
- .validateDelegate("[type='radio'], [type='checkbox'], select, option", "click", delegate);
376
+ // Support: Chrome, oldIE
377
+ // "select" is provided as event.target when clicking a option
378
+ .validateDelegate("select, option, [type='radio'], [type='checkbox']", "click", delegate);
358
379
 
359
380
  if ( this.settings.invalidHandler ) {
360
- $(this.currentForm).bind("invalid-form.validate", this.settings.invalidHandler);
381
+ $( this.currentForm ).bind( "invalid-form.validate", this.settings.invalidHandler );
361
382
  }
362
383
 
363
384
  // Add aria-required to any Static/Data/Class required fields before first validation
364
385
  // Screen readers require this attribute to be present before the initial submission http://www.w3.org/TR/WCAG-TECHS/ARIA2.html
365
- $(this.currentForm).find("[required], [data-rule-required], .required").attr("aria-required", "true");
386
+ $( this.currentForm ).find( "[required], [data-rule-required], .required" ).attr( "aria-required", "true" );
366
387
  },
367
388
 
368
389
  // http://jqueryvalidation.org/Validator.form/
369
390
  form: function() {
370
391
  this.checkForm();
371
- $.extend(this.submitted, this.errorMap);
372
- this.invalid = $.extend({}, this.errorMap);
392
+ $.extend( this.submitted, this.errorMap );
393
+ this.invalid = $.extend({}, this.errorMap );
373
394
  if ( !this.valid() ) {
374
- $(this.currentForm).triggerHandler("invalid-form", [ this ]);
395
+ $( this.currentForm ).triggerHandler( "invalid-form", [ this ]);
375
396
  }
376
397
  this.showErrors();
377
398
  return this.valid();
@@ -379,8 +400,8 @@ $.extend($.validator, {
379
400
 
380
401
  checkForm: function() {
381
402
  this.prepareForm();
382
- for ( var i = 0, elements = (this.currentElements = this.elements()); elements[i]; i++ ) {
383
- this.check( elements[i] );
403
+ for ( var i = 0, elements = ( this.currentElements = this.elements() ); elements[ i ]; i++ ) {
404
+ this.check( elements[ i ] );
384
405
  }
385
406
  return this.valid();
386
407
  },
@@ -400,10 +421,10 @@ $.extend($.validator, {
400
421
  this.currentElements = $( checkElement );
401
422
 
402
423
  result = this.check( checkElement ) !== false;
403
- if (result) {
404
- delete this.invalid[checkElement.name];
424
+ if ( result ) {
425
+ delete this.invalid[ checkElement.name ];
405
426
  } else {
406
- this.invalid[checkElement.name] = true;
427
+ this.invalid[ checkElement.name ] = true;
407
428
  }
408
429
  }
409
430
  // Add aria-invalid status for screen readers
@@ -425,13 +446,13 @@ $.extend($.validator, {
425
446
  this.errorList = [];
426
447
  for ( var name in errors ) {
427
448
  this.errorList.push({
428
- message: errors[name],
429
- element: this.findByName(name)[0]
449
+ message: errors[ name ],
450
+ element: this.findByName( name )[ 0 ]
430
451
  });
431
452
  }
432
453
  // remove items from success list
433
454
  this.successList = $.grep( this.successList, function( element ) {
434
- return !(element.name in errors);
455
+ return !( element.name in errors );
435
456
  });
436
457
  }
437
458
  if ( this.settings.showErrors ) {
@@ -444,7 +465,7 @@ $.extend($.validator, {
444
465
  // http://jqueryvalidation.org/Validator.resetForm/
445
466
  resetForm: function() {
446
467
  if ( $.fn.resetForm ) {
447
- $(this.currentForm).resetForm();
468
+ $( this.currentForm ).resetForm();
448
469
  }
449
470
  this.submitted = {};
450
471
  this.lastElement = null;
@@ -457,7 +478,7 @@ $.extend($.validator, {
457
478
  },
458
479
 
459
480
  numberOfInvalids: function() {
460
- return this.objectLength(this.invalid);
481
+ return this.objectLength( this.invalid );
461
482
  },
462
483
 
463
484
  objectLength: function( obj ) {
@@ -471,7 +492,12 @@ $.extend($.validator, {
471
492
  },
472
493
 
473
494
  hideErrors: function() {
474
- this.addWrapper( this.toHide ).hide();
495
+ this.hideThese( this.toHide );
496
+ },
497
+
498
+ hideThese: function( errors ) {
499
+ errors.not( this.containers ).text( "" );
500
+ this.addWrapper( errors ).hide();
475
501
  },
476
502
 
477
503
  valid: function() {
@@ -485,12 +511,12 @@ $.extend($.validator, {
485
511
  focusInvalid: function() {
486
512
  if ( this.settings.focusInvalid ) {
487
513
  try {
488
- $(this.findLastActive() || this.errorList.length && this.errorList[0].element || [])
489
- .filter(":visible")
514
+ $( this.findLastActive() || this.errorList.length && this.errorList[ 0 ].element || [])
515
+ .filter( ":visible" )
490
516
  .focus()
491
517
  // manually trigger focusin event; without it, focusin handler isn't called, findLastActive won't have anything to find
492
- .trigger("focusin");
493
- } catch(e) {
518
+ .trigger( "focusin" );
519
+ } catch ( e ) {
494
520
  // ignore IE throwing errors when focusing hidden elements
495
521
  }
496
522
  }
@@ -498,7 +524,7 @@ $.extend($.validator, {
498
524
 
499
525
  findLastActive: function() {
500
526
  var lastActive = this.lastActive;
501
- return lastActive && $.grep(this.errorList, function( n ) {
527
+ return lastActive && $.grep( this.errorList, function( n ) {
502
528
  return n.element.name === lastActive.name;
503
529
  }).length === 1 && lastActive;
504
530
  },
@@ -508,41 +534,41 @@ $.extend($.validator, {
508
534
  rulesCache = {};
509
535
 
510
536
  // select all valid inputs inside the form (no submit or reset buttons)
511
- return $(this.currentForm)
512
- .find("input, select, textarea")
513
- .not(":submit, :reset, :image, [disabled]")
537
+ return $( this.currentForm )
538
+ .find( "input, select, textarea" )
539
+ .not( ":submit, :reset, :image, [disabled], [readonly]" )
514
540
  .not( this.settings.ignore )
515
- .filter(function() {
541
+ .filter( function() {
516
542
  if ( !this.name && validator.settings.debug && window.console ) {
517
- console.error( "%o has no name assigned", this);
543
+ console.error( "%o has no name assigned", this );
518
544
  }
519
545
 
520
546
  // select only the first element for each name, and only those with rules specified
521
- if ( this.name in rulesCache || !validator.objectLength($(this).rules()) ) {
547
+ if ( this.name in rulesCache || !validator.objectLength( $( this ).rules() ) ) {
522
548
  return false;
523
549
  }
524
550
 
525
- rulesCache[this.name] = true;
551
+ rulesCache[ this.name ] = true;
526
552
  return true;
527
553
  });
528
554
  },
529
555
 
530
556
  clean: function( selector ) {
531
- return $(selector)[0];
557
+ return $( selector )[ 0 ];
532
558
  },
533
559
 
534
560
  errors: function() {
535
- var errorClass = this.settings.errorClass.split(" ").join(".");
536
- return $(this.settings.errorElement + "." + errorClass, this.errorContext);
561
+ var errorClass = this.settings.errorClass.split( " " ).join( "." );
562
+ return $( this.settings.errorElement + "." + errorClass, this.errorContext );
537
563
  },
538
564
 
539
565
  reset: function() {
540
566
  this.successList = [];
541
567
  this.errorList = [];
542
568
  this.errorMap = {};
543
- this.toShow = $([]);
544
- this.toHide = $([]);
545
- this.currentElements = $([]);
569
+ this.toShow = $( [] );
570
+ this.toHide = $( [] );
571
+ this.currentElements = $( [] );
546
572
  },
547
573
 
548
574
  prepareForm: function() {
@@ -552,21 +578,23 @@ $.extend($.validator, {
552
578
 
553
579
  prepareElement: function( element ) {
554
580
  this.reset();
555
- this.toHide = this.errorsFor(element);
581
+ this.toHide = this.errorsFor( element );
556
582
  },
557
583
 
558
584
  elementValue: function( element ) {
559
585
  var val,
560
- $element = $(element),
561
- type = $element.attr("type");
586
+ $element = $( element ),
587
+ type = element.type;
562
588
 
563
589
  if ( type === "radio" || type === "checkbox" ) {
564
- return $("input[name='" + $element.attr("name") + "']:checked").val();
590
+ return $( "input[name='" + element.name + "']:checked" ).val();
591
+ } else if ( type === "number" && typeof element.validity !== "undefined" ) {
592
+ return element.validity.badInput ? false : $element.val();
565
593
  }
566
594
 
567
595
  val = $element.val();
568
596
  if ( typeof val === "string" ) {
569
- return val.replace(/\r/g, "");
597
+ return val.replace(/\r/g, "" );
570
598
  }
571
599
  return val;
572
600
  },
@@ -574,19 +602,19 @@ $.extend($.validator, {
574
602
  check: function( element ) {
575
603
  element = this.validationTargetFor( this.clean( element ) );
576
604
 
577
- var rules = $(element).rules(),
578
- rulesCount = $.map( rules, function(n, i) {
605
+ var rules = $( element ).rules(),
606
+ rulesCount = $.map( rules, function( n, i ) {
579
607
  return i;
580
608
  }).length,
581
609
  dependencyMismatch = false,
582
- val = this.elementValue(element),
610
+ val = this.elementValue( element ),
583
611
  result, method, rule;
584
612
 
585
- for (method in rules ) {
586
- rule = { method: method, parameters: rules[method] };
613
+ for ( method in rules ) {
614
+ rule = { method: method, parameters: rules[ method ] };
587
615
  try {
588
616
 
589
- result = $.validator.methods[method].call( this, val, element, rule.parameters );
617
+ result = $.validator.methods[ method ].call( this, val, element, rule.parameters );
590
618
 
591
619
  // if a method indicates that the field is optional and therefore valid,
592
620
  // don't mark it as valid when there are no other rules
@@ -597,7 +625,7 @@ $.extend($.validator, {
597
625
  dependencyMismatch = false;
598
626
 
599
627
  if ( result === "pending" ) {
600
- this.toHide = this.toHide.not( this.errorsFor(element) );
628
+ this.toHide = this.toHide.not( this.errorsFor( element ) );
601
629
  return;
602
630
  }
603
631
 
@@ -605,7 +633,7 @@ $.extend($.validator, {
605
633
  this.formatAndAdd( element, rule );
606
634
  return false;
607
635
  }
608
- } catch(e) {
636
+ } catch ( e ) {
609
637
  if ( this.settings.debug && window.console ) {
610
638
  console.log( "Exception occurred when checking element " + element.id + ", check the '" + rule.method + "' method.", e );
611
639
  }
@@ -615,8 +643,8 @@ $.extend($.validator, {
615
643
  if ( dependencyMismatch ) {
616
644
  return;
617
645
  }
618
- if ( this.objectLength(rules) ) {
619
- this.successList.push(element);
646
+ if ( this.objectLength( rules ) ) {
647
+ this.successList.push( element );
620
648
  }
621
649
  return true;
622
650
  },
@@ -625,21 +653,21 @@ $.extend($.validator, {
625
653
  // specified in the element's HTML5 data attribute
626
654
  // return the generic message if present and no method specific message is present
627
655
  customDataMessage: function( element, method ) {
628
- return $( element ).data( "msg" + method[ 0 ].toUpperCase() +
629
- method.substring( 1 ).toLowerCase() ) || $( element ).data("msg");
656
+ return $( element ).data( "msg" + method.charAt( 0 ).toUpperCase() +
657
+ method.substring( 1 ).toLowerCase() ) || $( element ).data( "msg" );
630
658
  },
631
659
 
632
660
  // return the custom message for the given element name and validation method
633
661
  customMessage: function( name, method ) {
634
- var m = this.settings.messages[name];
635
- return m && (m.constructor === String ? m : m[method]);
662
+ var m = this.settings.messages[ name ];
663
+ return m && ( m.constructor === String ? m : m[ method ]);
636
664
  },
637
665
 
638
666
  // return the first defined argument, allowing empty strings
639
667
  findDefined: function() {
640
- for (var i = 0; i < arguments.length; i++) {
641
- if ( arguments[i] !== undefined ) {
642
- return arguments[i];
668
+ for ( var i = 0; i < arguments.length; i++) {
669
+ if ( arguments[ i ] !== undefined ) {
670
+ return arguments[ i ];
643
671
  }
644
672
  }
645
673
  return undefined;
@@ -651,7 +679,7 @@ $.extend($.validator, {
651
679
  this.customDataMessage( element, method ),
652
680
  // title is never undefined, so handle empty string as undefined
653
681
  !this.settings.ignoreTitle && element.title || undefined,
654
- $.validator.messages[method],
682
+ $.validator.messages[ method ],
655
683
  "<strong>Warning: No message defined for " + element.name + "</strong>"
656
684
  );
657
685
  },
@@ -660,9 +688,9 @@ $.extend($.validator, {
660
688
  var message = this.defaultMessage( element, rule.method ),
661
689
  theregex = /\$?\{(\d+)\}/g;
662
690
  if ( typeof message === "function" ) {
663
- message = message.call(this, rule.parameters, element);
664
- } else if (theregex.test(message)) {
665
- message = $.validator.format(message.replace(theregex, "{$1}"), rule.parameters);
691
+ message = message.call( this, rule.parameters, element );
692
+ } else if ( theregex.test( message ) ) {
693
+ message = $.validator.format( message.replace( theregex, "{$1}" ), rule.parameters );
666
694
  }
667
695
  this.errorList.push({
668
696
  message: message,
@@ -670,8 +698,8 @@ $.extend($.validator, {
670
698
  method: rule.method
671
699
  });
672
700
 
673
- this.errorMap[element.name] = message;
674
- this.submitted[element.name] = message;
701
+ this.errorMap[ element.name ] = message;
702
+ this.submitted[ element.name ] = message;
675
703
  },
676
704
 
677
705
  addWrapper: function( toToggle ) {
@@ -683,8 +711,8 @@ $.extend($.validator, {
683
711
 
684
712
  defaultShowErrors: function() {
685
713
  var i, elements, error;
686
- for ( i = 0; this.errorList[i]; i++ ) {
687
- error = this.errorList[i];
714
+ for ( i = 0; this.errorList[ i ]; i++ ) {
715
+ error = this.errorList[ i ];
688
716
  if ( this.settings.highlight ) {
689
717
  this.settings.highlight.call( this, error.element, this.settings.errorClass, this.settings.validClass );
690
718
  }
@@ -694,13 +722,13 @@ $.extend($.validator, {
694
722
  this.toShow = this.toShow.add( this.containers );
695
723
  }
696
724
  if ( this.settings.success ) {
697
- for ( i = 0; this.successList[i]; i++ ) {
698
- this.showLabel( this.successList[i] );
725
+ for ( i = 0; this.successList[ i ]; i++ ) {
726
+ this.showLabel( this.successList[ i ] );
699
727
  }
700
728
  }
701
729
  if ( this.settings.unhighlight ) {
702
- for ( i = 0, elements = this.validElements(); elements[i]; i++ ) {
703
- this.settings.unhighlight.call( this, elements[i], this.settings.errorClass, this.settings.validClass );
730
+ for ( i = 0, elements = this.validElements(); elements[ i ]; i++ ) {
731
+ this.settings.unhighlight.call( this, elements[ i ], this.settings.errorClass, this.settings.validClass );
704
732
  }
705
733
  }
706
734
  this.toHide = this.toHide.not( this.toShow );
@@ -709,93 +737,139 @@ $.extend($.validator, {
709
737
  },
710
738
 
711
739
  validElements: function() {
712
- return this.currentElements.not(this.invalidElements());
740
+ return this.currentElements.not( this.invalidElements() );
713
741
  },
714
742
 
715
743
  invalidElements: function() {
716
- return $(this.errorList).map(function() {
744
+ return $( this.errorList ).map(function() {
717
745
  return this.element;
718
746
  });
719
747
  },
720
748
 
721
749
  showLabel: function( element, message ) {
722
- var label = this.errorsFor( element );
723
- if ( label.length ) {
750
+ var place, group, errorID,
751
+ error = this.errorsFor( element ),
752
+ elementID = this.idOrName( element ),
753
+ describedBy = $( element ).attr( "aria-describedby" );
754
+ if ( error.length ) {
724
755
  // refresh error/success class
725
- label.removeClass( this.settings.validClass ).addClass( this.settings.errorClass );
756
+ error.removeClass( this.settings.validClass ).addClass( this.settings.errorClass );
726
757
  // replace message on existing label
727
- label.html(message);
758
+ error.html( message );
728
759
  } else {
729
- // create label
730
- label = $("<" + this.settings.errorElement + ">")
731
- .attr("for", this.idOrName(element))
732
- .addClass(this.settings.errorClass)
733
- .html(message || "");
760
+ // create error element
761
+ error = $( "<" + this.settings.errorElement + ">" )
762
+ .attr( "id", elementID + "-error" )
763
+ .addClass( this.settings.errorClass )
764
+ .html( message || "" );
765
+
766
+ // Maintain reference to the element to be placed into the DOM
767
+ place = error;
734
768
  if ( this.settings.wrapper ) {
735
769
  // make sure the element is visible, even in IE
736
770
  // actually showing the wrapped element is handled elsewhere
737
- label = label.hide().show().wrap("<" + this.settings.wrapper + "/>").parent();
771
+ place = error.hide().show().wrap( "<" + this.settings.wrapper + "/>" ).parent();
738
772
  }
739
- if ( !this.labelContainer.append(label).length ) {
740
- if ( this.settings.errorPlacement ) {
741
- this.settings.errorPlacement(label, $(element) );
742
- } else {
743
- label.insertAfter(element);
773
+ if ( this.labelContainer.length ) {
774
+ this.labelContainer.append( place );
775
+ } else if ( this.settings.errorPlacement ) {
776
+ this.settings.errorPlacement( place, $( element ) );
777
+ } else {
778
+ place.insertAfter( element );
779
+ }
780
+
781
+ // Link error back to the element
782
+ if ( error.is( "label" ) ) {
783
+ // If the error is a label, then associate using 'for'
784
+ error.attr( "for", elementID );
785
+ } else if ( error.parents( "label[for='" + elementID + "']" ).length === 0 ) {
786
+ // If the element is not a child of an associated label, then it's necessary
787
+ // to explicitly apply aria-describedby
788
+
789
+ errorID = error.attr( "id" ).replace( /(:|\.|\[|\])/g, "\\$1");
790
+ // Respect existing non-error aria-describedby
791
+ if ( !describedBy ) {
792
+ describedBy = errorID;
793
+ } else if ( !describedBy.match( new RegExp( "\\b" + errorID + "\\b" ) ) ) {
794
+ // Add to end of list if not already present
795
+ describedBy += " " + errorID;
796
+ }
797
+ $( element ).attr( "aria-describedby", describedBy );
798
+
799
+ // If this element is grouped, then assign to all elements in the same group
800
+ group = this.groups[ element.name ];
801
+ if ( group ) {
802
+ $.each( this.groups, function( name, testgroup ) {
803
+ if ( testgroup === group ) {
804
+ $( "[name='" + name + "']", this.currentForm )
805
+ .attr( "aria-describedby", error.attr( "id" ) );
806
+ }
807
+ });
744
808
  }
745
809
  }
746
810
  }
747
811
  if ( !message && this.settings.success ) {
748
- label.text("");
812
+ error.text( "" );
749
813
  if ( typeof this.settings.success === "string" ) {
750
- label.addClass( this.settings.success );
814
+ error.addClass( this.settings.success );
751
815
  } else {
752
- this.settings.success( label, element );
816
+ this.settings.success( error, element );
753
817
  }
754
818
  }
755
- this.toShow = this.toShow.add(label);
819
+ this.toShow = this.toShow.add( error );
756
820
  },
757
821
 
758
822
  errorsFor: function( element ) {
759
- var name = this.idOrName(element);
760
- return this.errors().filter(function() {
761
- return $(this).attr("for") === name;
762
- });
823
+ var name = this.idOrName( element ),
824
+ describer = $( element ).attr( "aria-describedby" ),
825
+ selector = "label[for='" + name + "'], label[for='" + name + "'] *";
826
+
827
+ // aria-describedby should directly reference the error element
828
+ if ( describer ) {
829
+ selector = selector + ", #" + describer.replace( /\s+/g, ", #" );
830
+ }
831
+ return this
832
+ .errors()
833
+ .filter( selector );
763
834
  },
764
835
 
765
836
  idOrName: function( element ) {
766
- return this.groups[element.name] || (this.checkable(element) ? element.name : element.id || element.name);
837
+ return this.groups[ element.name ] || ( this.checkable( element ) ? element.name : element.id || element.name );
767
838
  },
768
839
 
769
840
  validationTargetFor: function( element ) {
770
- // if radio/checkbox, validate first element in group instead
771
- if ( this.checkable(element) ) {
772
- element = this.findByName( element.name ).not(this.settings.ignore)[0];
841
+
842
+ // If radio/checkbox, validate first element in group instead
843
+ if ( this.checkable( element ) ) {
844
+ element = this.findByName( element.name );
773
845
  }
774
- return element;
846
+
847
+ // Always apply ignore filter
848
+ return $( element ).not( this.settings.ignore )[ 0 ];
775
849
  },
776
850
 
777
851
  checkable: function( element ) {
778
- return (/radio|checkbox/i).test(element.type);
852
+ return ( /radio|checkbox/i ).test( element.type );
779
853
  },
780
854
 
781
855
  findByName: function( name ) {
782
- return $(this.currentForm).find("[name='" + name + "']");
856
+ return $( this.currentForm ).find( "[name='" + name + "']" );
783
857
  },
784
858
 
785
859
  getLength: function( value, element ) {
786
860
  switch ( element.nodeName.toLowerCase() ) {
787
861
  case "select":
788
- return $("option:selected", element).length;
862
+ return $( "option:selected", element ).length;
789
863
  case "input":
790
- if ( this.checkable( element) ) {
791
- return this.findByName(element.name).filter(":checked").length;
864
+ if ( this.checkable( element ) ) {
865
+ return this.findByName( element.name ).filter( ":checked" ).length;
792
866
  }
793
867
  }
794
868
  return value.length;
795
869
  },
796
870
 
797
871
  depend: function( param, element ) {
798
- return this.dependTypes[typeof param] ? this.dependTypes[typeof param](param, element) : true;
872
+ return this.dependTypes[typeof param] ? this.dependTypes[typeof param]( param, element ) : true;
799
873
  },
800
874
 
801
875
  dependTypes: {
@@ -803,22 +877,22 @@ $.extend($.validator, {
803
877
  return param;
804
878
  },
805
879
  "string": function( param, element ) {
806
- return !!$(param, element.form).length;
880
+ return !!$( param, element.form ).length;
807
881
  },
808
882
  "function": function( param, element ) {
809
- return param(element);
883
+ return param( element );
810
884
  }
811
885
  },
812
886
 
813
887
  optional: function( element ) {
814
- var val = this.elementValue(element);
815
- return !$.validator.methods.required.call(this, val, element) && "dependency-mismatch";
888
+ var val = this.elementValue( element );
889
+ return !$.validator.methods.required.call( this, val, element ) && "dependency-mismatch";
816
890
  },
817
891
 
818
892
  startRequest: function( element ) {
819
- if ( !this.pending[element.name] ) {
893
+ if ( !this.pending[ element.name ] ) {
820
894
  this.pendingRequest++;
821
- this.pending[element.name] = true;
895
+ this.pending[ element.name ] = true;
822
896
  }
823
897
  },
824
898
 
@@ -828,18 +902,18 @@ $.extend($.validator, {
828
902
  if ( this.pendingRequest < 0 ) {
829
903
  this.pendingRequest = 0;
830
904
  }
831
- delete this.pending[element.name];
905
+ delete this.pending[ element.name ];
832
906
  if ( valid && this.pendingRequest === 0 && this.formSubmitted && this.form() ) {
833
- $(this.currentForm).submit();
907
+ $( this.currentForm ).submit();
834
908
  this.formSubmitted = false;
835
- } else if (!valid && this.pendingRequest === 0 && this.formSubmitted) {
836
- $(this.currentForm).triggerHandler("invalid-form", [ this ]);
909
+ } else if (!valid && this.pendingRequest === 0 && this.formSubmitted ) {
910
+ $( this.currentForm ).triggerHandler( "invalid-form", [ this ]);
837
911
  this.formSubmitted = false;
838
912
  }
839
913
  },
840
914
 
841
915
  previousValue: function( element ) {
842
- return $.data(element, "previousValue") || $.data(element, "previousValue", {
916
+ return $.data( element, "previousValue" ) || $.data( element, "previousValue", {
843
917
  old: null,
844
918
  valid: true,
845
919
  message: this.defaultMessage( element, "remote" )
@@ -861,20 +935,20 @@ $.extend($.validator, {
861
935
 
862
936
  addClassRules: function( className, rules ) {
863
937
  if ( className.constructor === String ) {
864
- this.classRuleSettings[className] = rules;
938
+ this.classRuleSettings[ className ] = rules;
865
939
  } else {
866
- $.extend(this.classRuleSettings, className);
940
+ $.extend( this.classRuleSettings, className );
867
941
  }
868
942
  },
869
943
 
870
944
  classRules: function( element ) {
871
945
  var rules = {},
872
- classes = $(element).attr("class");
946
+ classes = $( element ).attr( "class" );
873
947
 
874
948
  if ( classes ) {
875
- $.each(classes.split(" "), function() {
949
+ $.each( classes.split( " " ), function() {
876
950
  if ( this in $.validator.classRuleSettings ) {
877
- $.extend(rules, $.validator.classRuleSettings[this]);
951
+ $.extend( rules, $.validator.classRuleSettings[ this ]);
878
952
  }
879
953
  });
880
954
  }
@@ -883,15 +957,15 @@ $.extend($.validator, {
883
957
 
884
958
  attributeRules: function( element ) {
885
959
  var rules = {},
886
- $element = $(element),
887
- type = element.getAttribute("type"),
960
+ $element = $( element ),
961
+ type = element.getAttribute( "type" ),
888
962
  method, value;
889
963
 
890
- for (method in $.validator.methods) {
964
+ for ( method in $.validator.methods ) {
891
965
 
892
966
  // support for <input required> in both html5 and older browsers
893
967
  if ( method === "required" ) {
894
- value = element.getAttribute(method);
968
+ value = element.getAttribute( method );
895
969
  // Some browsers return an empty string for the required attribute
896
970
  // and non-HTML5 browsers might have required="" markup
897
971
  if ( value === "" ) {
@@ -900,26 +974,26 @@ $.extend($.validator, {
900
974
  // force non-HTML5 browsers to return bool
901
975
  value = !!value;
902
976
  } else {
903
- value = $element.attr(method);
977
+ value = $element.attr( method );
904
978
  }
905
979
 
906
980
  // convert the value to a number for number inputs, and for text for backwards compability
907
981
  // allows type="date" and others to be compared as strings
908
982
  if ( /min|max/.test( method ) && ( type === null || /number|range|text/.test( type ) ) ) {
909
- value = Number(value);
983
+ value = Number( value );
910
984
  }
911
985
 
912
986
  if ( value || value === 0 ) {
913
- rules[method] = value;
987
+ rules[ method ] = value;
914
988
  } else if ( type === method && type !== "range" ) {
915
989
  // exception: the jquery validate 'range' method
916
990
  // does not test for the html5 'range' type
917
- rules[method] = true;
991
+ rules[ method ] = true;
918
992
  }
919
993
  }
920
994
 
921
- // maxlength may be returned as -1, 2147483647 (IE) and 524288 (safari) for text inputs
922
- if ( rules.maxlength && /-1|2147483647|524288/.test(rules.maxlength) ) {
995
+ // maxlength may be returned as -1, 2147483647 ( IE ) and 524288 ( safari ) for text inputs
996
+ if ( rules.maxlength && /-1|2147483647|524288/.test( rules.maxlength ) ) {
923
997
  delete rules.maxlength;
924
998
  }
925
999
 
@@ -930,7 +1004,7 @@ $.extend($.validator, {
930
1004
  var method, value,
931
1005
  rules = {}, $element = $( element );
932
1006
  for ( method in $.validator.methods ) {
933
- value = $element.data( "rule" + method[ 0 ].toUpperCase() + method.substring( 1 ).toLowerCase() );
1007
+ value = $element.data( "rule" + method.charAt( 0 ).toUpperCase() + method.substring( 1 ).toLowerCase() );
934
1008
  if ( value !== undefined ) {
935
1009
  rules[ method ] = value;
936
1010
  }
@@ -940,71 +1014,71 @@ $.extend($.validator, {
940
1014
 
941
1015
  staticRules: function( element ) {
942
1016
  var rules = {},
943
- validator = $.data(element.form, "validator");
1017
+ validator = $.data( element.form, "validator" );
944
1018
 
945
1019
  if ( validator.settings.rules ) {
946
- rules = $.validator.normalizeRule(validator.settings.rules[element.name]) || {};
1020
+ rules = $.validator.normalizeRule( validator.settings.rules[ element.name ] ) || {};
947
1021
  }
948
1022
  return rules;
949
1023
  },
950
1024
 
951
1025
  normalizeRules: function( rules, element ) {
952
1026
  // handle dependency check
953
- $.each(rules, function( prop, val ) {
1027
+ $.each( rules, function( prop, val ) {
954
1028
  // ignore rule when param is explicitly false, eg. required:false
955
1029
  if ( val === false ) {
956
- delete rules[prop];
1030
+ delete rules[ prop ];
957
1031
  return;
958
1032
  }
959
1033
  if ( val.param || val.depends ) {
960
1034
  var keepRule = true;
961
- switch (typeof val.depends) {
1035
+ switch ( typeof val.depends ) {
962
1036
  case "string":
963
- keepRule = !!$(val.depends, element.form).length;
1037
+ keepRule = !!$( val.depends, element.form ).length;
964
1038
  break;
965
1039
  case "function":
966
- keepRule = val.depends.call(element, element);
1040
+ keepRule = val.depends.call( element, element );
967
1041
  break;
968
1042
  }
969
1043
  if ( keepRule ) {
970
- rules[prop] = val.param !== undefined ? val.param : true;
1044
+ rules[ prop ] = val.param !== undefined ? val.param : true;
971
1045
  } else {
972
- delete rules[prop];
1046
+ delete rules[ prop ];
973
1047
  }
974
1048
  }
975
1049
  });
976
1050
 
977
1051
  // evaluate parameters
978
- $.each(rules, function( rule, parameter ) {
979
- rules[rule] = $.isFunction(parameter) ? parameter(element) : parameter;
1052
+ $.each( rules, function( rule, parameter ) {
1053
+ rules[ rule ] = $.isFunction( parameter ) ? parameter( element ) : parameter;
980
1054
  });
981
1055
 
982
1056
  // clean number parameters
983
1057
  $.each([ "minlength", "maxlength" ], function() {
984
- if ( rules[this] ) {
985
- rules[this] = Number(rules[this]);
1058
+ if ( rules[ this ] ) {
1059
+ rules[ this ] = Number( rules[ this ] );
986
1060
  }
987
1061
  });
988
1062
  $.each([ "rangelength", "range" ], function() {
989
1063
  var parts;
990
- if ( rules[this] ) {
991
- if ( $.isArray(rules[this]) ) {
992
- rules[this] = [ Number(rules[this][0]), Number(rules[this][1]) ];
993
- } else if ( typeof rules[this] === "string" ) {
994
- parts = rules[this].split(/[\s,]+/);
995
- rules[this] = [ Number(parts[0]), Number(parts[1]) ];
1064
+ if ( rules[ this ] ) {
1065
+ if ( $.isArray( rules[ this ] ) ) {
1066
+ rules[ this ] = [ Number( rules[ this ][ 0 ]), Number( rules[ this ][ 1 ] ) ];
1067
+ } else if ( typeof rules[ this ] === "string" ) {
1068
+ parts = rules[ this ].replace(/[\[\]]/g, "" ).split( /[\s,]+/ );
1069
+ rules[ this ] = [ Number( parts[ 0 ]), Number( parts[ 1 ] ) ];
996
1070
  }
997
1071
  }
998
1072
  });
999
1073
 
1000
1074
  if ( $.validator.autoCreateRanges ) {
1001
1075
  // auto-create ranges
1002
- if ( rules.min && rules.max ) {
1076
+ if ( rules.min != null && rules.max != null ) {
1003
1077
  rules.range = [ rules.min, rules.max ];
1004
1078
  delete rules.min;
1005
1079
  delete rules.max;
1006
1080
  }
1007
- if ( rules.minlength && rules.maxlength ) {
1081
+ if ( rules.minlength != null && rules.maxlength != null ) {
1008
1082
  rules.rangelength = [ rules.minlength, rules.maxlength ];
1009
1083
  delete rules.minlength;
1010
1084
  delete rules.maxlength;
@@ -1018,8 +1092,8 @@ $.extend($.validator, {
1018
1092
  normalizeRule: function( data ) {
1019
1093
  if ( typeof data === "string" ) {
1020
1094
  var transformed = {};
1021
- $.each(data.split(/\s/), function() {
1022
- transformed[this] = true;
1095
+ $.each( data.split( /\s/ ), function() {
1096
+ transformed[ this ] = true;
1023
1097
  });
1024
1098
  data = transformed;
1025
1099
  }
@@ -1028,10 +1102,10 @@ $.extend($.validator, {
1028
1102
 
1029
1103
  // http://jqueryvalidation.org/jQuery.validator.addMethod/
1030
1104
  addMethod: function( name, method, message ) {
1031
- $.validator.methods[name] = method;
1032
- $.validator.messages[name] = message !== undefined ? message : $.validator.messages[name];
1105
+ $.validator.methods[ name ] = method;
1106
+ $.validator.messages[ name ] = message !== undefined ? message : $.validator.messages[ name ];
1033
1107
  if ( method.length < 3 ) {
1034
- $.validator.addClassRules(name, $.validator.normalizeRule(name));
1108
+ $.validator.addClassRules( name, $.validator.normalizeRule( name ) );
1035
1109
  }
1036
1110
  },
1037
1111
 
@@ -1040,18 +1114,18 @@ $.extend($.validator, {
1040
1114
  // http://jqueryvalidation.org/required-method/
1041
1115
  required: function( value, element, param ) {
1042
1116
  // check if dependency is met
1043
- if ( !this.depend(param, element) ) {
1117
+ if ( !this.depend( param, element ) ) {
1044
1118
  return "dependency-mismatch";
1045
1119
  }
1046
1120
  if ( element.nodeName.toLowerCase() === "select" ) {
1047
1121
  // could be an array for select-multiple or a string, both are fine this way
1048
- var val = $(element).val();
1122
+ var val = $( element ).val();
1049
1123
  return val && val.length > 0;
1050
1124
  }
1051
- if ( this.checkable(element) ) {
1052
- return this.getLength(value, element) > 0;
1125
+ if ( this.checkable( element ) ) {
1126
+ return this.getLength( value, element ) > 0;
1053
1127
  }
1054
- return $.trim(value).length > 0;
1128
+ return $.trim( value ).length > 0;
1055
1129
  },
1056
1130
 
1057
1131
  // http://jqueryvalidation.org/email-method/
@@ -1060,43 +1134,43 @@ $.extend($.validator, {
1060
1134
  // Retrieved 2014-01-14
1061
1135
  // If you have a problem with this implementation, report a bug against the above spec
1062
1136
  // Or use custom methods to implement your own email validation
1063
- return this.optional(element) || /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/.test(value);
1137
+ return this.optional( element ) || /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/.test( value );
1064
1138
  },
1065
1139
 
1066
1140
  // http://jqueryvalidation.org/url-method/
1067
1141
  url: function( value, element ) {
1068
1142
  // contributed by Scott Gonzalez: http://projects.scottsplayground.com/iri/
1069
- return this.optional(element) || /^(https?|s?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);
1143
+ return this.optional( element ) || /^(https?|s?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 );
1070
1144
  },
1071
1145
 
1072
1146
  // http://jqueryvalidation.org/date-method/
1073
1147
  date: function( value, element ) {
1074
- return this.optional(element) || !/Invalid|NaN/.test(new Date(value).toString());
1148
+ return this.optional( element ) || !/Invalid|NaN/.test( new Date( value ).toString() );
1075
1149
  },
1076
1150
 
1077
1151
  // http://jqueryvalidation.org/dateISO-method/
1078
1152
  dateISO: function( value, element ) {
1079
- return this.optional(element) || /^\d{4}[\/\-]\d{1,2}[\/\-]\d{1,2}$/.test(value);
1153
+ return this.optional( element ) || /^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$/.test( value );
1080
1154
  },
1081
1155
 
1082
1156
  // http://jqueryvalidation.org/number-method/
1083
1157
  number: function( value, element ) {
1084
- return this.optional(element) || /^-?(?:\d+|\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/.test(value);
1158
+ return this.optional( element ) || /^-?(?:\d+|\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/.test( value );
1085
1159
  },
1086
1160
 
1087
1161
  // http://jqueryvalidation.org/digits-method/
1088
1162
  digits: function( value, element ) {
1089
- return this.optional(element) || /^\d+$/.test(value);
1163
+ return this.optional( element ) || /^\d+$/.test( value );
1090
1164
  },
1091
1165
 
1092
1166
  // http://jqueryvalidation.org/creditcard-method/
1093
1167
  // based on http://en.wikipedia.org/wiki/Luhn/
1094
1168
  creditcard: function( value, element ) {
1095
- if ( this.optional(element) ) {
1169
+ if ( this.optional( element ) ) {
1096
1170
  return "dependency-mismatch";
1097
1171
  }
1098
1172
  // accept only spaces, digits and dashes
1099
- if ( /[^0-9 \-]+/.test(value) ) {
1173
+ if ( /[^0-9 \-]+/.test( value ) ) {
1100
1174
  return false;
1101
1175
  }
1102
1176
  var nCheck = 0,
@@ -1104,7 +1178,7 @@ $.extend($.validator, {
1104
1178
  bEven = false,
1105
1179
  n, cDigit;
1106
1180
 
1107
- value = value.replace(/\D/g, "");
1181
+ value = value.replace( /\D/g, "" );
1108
1182
 
1109
1183
  // Basing min and max length on
1110
1184
  // http://developer.ean.com/general_info/Valid_Credit_Card_Types
@@ -1113,10 +1187,10 @@ $.extend($.validator, {
1113
1187
  }
1114
1188
 
1115
1189
  for ( n = value.length - 1; n >= 0; n--) {
1116
- cDigit = value.charAt(n);
1117
- nDigit = parseInt(cDigit, 10);
1190
+ cDigit = value.charAt( n );
1191
+ nDigit = parseInt( cDigit, 10 );
1118
1192
  if ( bEven ) {
1119
- if ( (nDigit *= 2) > 9 ) {
1193
+ if ( ( nDigit *= 2 ) > 9 ) {
1120
1194
  nDigit -= 9;
1121
1195
  }
1122
1196
  }
@@ -1124,50 +1198,50 @@ $.extend($.validator, {
1124
1198
  bEven = !bEven;
1125
1199
  }
1126
1200
 
1127
- return (nCheck % 10) === 0;
1201
+ return ( nCheck % 10 ) === 0;
1128
1202
  },
1129
1203
 
1130
1204
  // http://jqueryvalidation.org/minlength-method/
1131
1205
  minlength: function( value, element, param ) {
1132
- var length = $.isArray( value ) ? value.length : this.getLength($.trim(value), element);
1133
- return this.optional(element) || length >= param;
1206
+ var length = $.isArray( value ) ? value.length : this.getLength( value, element );
1207
+ return this.optional( element ) || length >= param;
1134
1208
  },
1135
1209
 
1136
1210
  // http://jqueryvalidation.org/maxlength-method/
1137
1211
  maxlength: function( value, element, param ) {
1138
- var length = $.isArray( value ) ? value.length : this.getLength($.trim(value), element);
1139
- return this.optional(element) || length <= param;
1212
+ var length = $.isArray( value ) ? value.length : this.getLength( value, element );
1213
+ return this.optional( element ) || length <= param;
1140
1214
  },
1141
1215
 
1142
1216
  // http://jqueryvalidation.org/rangelength-method/
1143
1217
  rangelength: function( value, element, param ) {
1144
- var length = $.isArray( value ) ? value.length : this.getLength($.trim(value), element);
1145
- return this.optional(element) || ( length >= param[0] && length <= param[1] );
1218
+ var length = $.isArray( value ) ? value.length : this.getLength( value, element );
1219
+ return this.optional( element ) || ( length >= param[ 0 ] && length <= param[ 1 ] );
1146
1220
  },
1147
1221
 
1148
1222
  // http://jqueryvalidation.org/min-method/
1149
1223
  min: function( value, element, param ) {
1150
- return this.optional(element) || value >= param;
1224
+ return this.optional( element ) || value >= param;
1151
1225
  },
1152
1226
 
1153
1227
  // http://jqueryvalidation.org/max-method/
1154
1228
  max: function( value, element, param ) {
1155
- return this.optional(element) || value <= param;
1229
+ return this.optional( element ) || value <= param;
1156
1230
  },
1157
1231
 
1158
1232
  // http://jqueryvalidation.org/range-method/
1159
1233
  range: function( value, element, param ) {
1160
- return this.optional(element) || ( value >= param[0] && value <= param[1] );
1234
+ return this.optional( element ) || ( value >= param[ 0 ] && value <= param[ 1 ] );
1161
1235
  },
1162
1236
 
1163
1237
  // http://jqueryvalidation.org/equalTo-method/
1164
1238
  equalTo: function( value, element, param ) {
1165
1239
  // bind to the blur event of the target in order to revalidate whenever the target field is updated
1166
1240
  // TODO find a way to bind the event just once, avoiding the unbind-rebind overhead
1167
- var target = $(param);
1241
+ var target = $( param );
1168
1242
  if ( this.settings.onfocusout ) {
1169
- target.unbind(".validate-equalTo").bind("blur.validate-equalTo", function() {
1170
- $(element).valid();
1243
+ target.unbind( ".validate-equalTo" ).bind( "blur.validate-equalTo", function() {
1244
+ $( element ).valid();
1171
1245
  });
1172
1246
  }
1173
1247
  return value === target.val();
@@ -1175,18 +1249,18 @@ $.extend($.validator, {
1175
1249
 
1176
1250
  // http://jqueryvalidation.org/remote-method/
1177
1251
  remote: function( value, element, param ) {
1178
- if ( this.optional(element) ) {
1252
+ if ( this.optional( element ) ) {
1179
1253
  return "dependency-mismatch";
1180
1254
  }
1181
1255
 
1182
- var previous = this.previousValue(element),
1256
+ var previous = this.previousValue( element ),
1183
1257
  validator, data;
1184
1258
 
1185
- if (!this.settings.messages[element.name] ) {
1186
- this.settings.messages[element.name] = {};
1259
+ if (!this.settings.messages[ element.name ] ) {
1260
+ this.settings.messages[ element.name ] = {};
1187
1261
  }
1188
- previous.originalMessage = this.settings.messages[element.name].remote;
1189
- this.settings.messages[element.name].remote = previous.message;
1262
+ previous.originalMessage = this.settings.messages[ element.name ].remote;
1263
+ this.settings.messages[ element.name ].remote = previous.message;
1190
1264
 
1191
1265
  param = typeof param === "string" && { url: param } || param;
1192
1266
 
@@ -1196,10 +1270,10 @@ $.extend($.validator, {
1196
1270
 
1197
1271
  previous.old = value;
1198
1272
  validator = this;
1199
- this.startRequest(element);
1273
+ this.startRequest( element );
1200
1274
  data = {};
1201
- data[element.name] = value;
1202
- $.ajax($.extend(true, {
1275
+ data[ element.name ] = value;
1276
+ $.ajax( $.extend( true, {
1203
1277
  url: param,
1204
1278
  mode: "abort",
1205
1279
  port: "validate" + element.name,
@@ -1210,25 +1284,25 @@ $.extend($.validator, {
1210
1284
  var valid = response === true || response === "true",
1211
1285
  errors, message, submitted;
1212
1286
 
1213
- validator.settings.messages[element.name].remote = previous.originalMessage;
1287
+ validator.settings.messages[ element.name ].remote = previous.originalMessage;
1214
1288
  if ( valid ) {
1215
1289
  submitted = validator.formSubmitted;
1216
- validator.prepareElement(element);
1290
+ validator.prepareElement( element );
1217
1291
  validator.formSubmitted = submitted;
1218
- validator.successList.push(element);
1219
- delete validator.invalid[element.name];
1292
+ validator.successList.push( element );
1293
+ delete validator.invalid[ element.name ];
1220
1294
  validator.showErrors();
1221
1295
  } else {
1222
1296
  errors = {};
1223
1297
  message = response || validator.defaultMessage( element, "remote" );
1224
- errors[element.name] = previous.message = $.isFunction(message) ? message(value) : message;
1225
- validator.invalid[element.name] = true;
1226
- validator.showErrors(errors);
1298
+ errors[ element.name ] = previous.message = $.isFunction( message ) ? message( value ) : message;
1299
+ validator.invalid[ element.name ] = true;
1300
+ validator.showErrors( errors );
1227
1301
  }
1228
1302
  previous.valid = valid;
1229
- validator.stopRequest(element, valid);
1303
+ validator.stopRequest( element, valid );
1230
1304
  }
1231
- }, param));
1305
+ }, param ) );
1232
1306
  return "pending";
1233
1307
  }
1234
1308
 
@@ -1240,54 +1314,52 @@ $.format = function deprecated() {
1240
1314
  throw "$.format has been deprecated. Please use $.validator.format instead.";
1241
1315
  };
1242
1316
 
1243
- }(jQuery));
1244
-
1245
1317
  // ajax mode: abort
1246
1318
  // usage: $.ajax({ mode: "abort"[, port: "uniqueport"]});
1247
1319
  // if mode:"abort" is used, the previous request on that port (port can be undefined) is aborted via XMLHttpRequest.abort()
1248
- (function($) {
1249
- var pendingRequests = {},
1250
- ajax;
1251
- // Use a prefilter if available (1.5+)
1252
- if ( $.ajaxPrefilter ) {
1253
- $.ajaxPrefilter(function( settings, _, xhr ) {
1254
- var port = settings.port;
1255
- if ( settings.mode === "abort" ) {
1256
- if ( pendingRequests[port] ) {
1257
- pendingRequests[port].abort();
1258
- }
1259
- pendingRequests[port] = xhr;
1320
+
1321
+ var pendingRequests = {},
1322
+ ajax;
1323
+ // Use a prefilter if available (1.5+)
1324
+ if ( $.ajaxPrefilter ) {
1325
+ $.ajaxPrefilter(function( settings, _, xhr ) {
1326
+ var port = settings.port;
1327
+ if ( settings.mode === "abort" ) {
1328
+ if ( pendingRequests[port] ) {
1329
+ pendingRequests[port].abort();
1260
1330
  }
1261
- });
1262
- } else {
1263
- // Proxy ajax
1264
- ajax = $.ajax;
1265
- $.ajax = function( settings ) {
1266
- var mode = ( "mode" in settings ? settings : $.ajaxSettings ).mode,
1267
- port = ( "port" in settings ? settings : $.ajaxSettings ).port;
1268
- if ( mode === "abort" ) {
1269
- if ( pendingRequests[port] ) {
1270
- pendingRequests[port].abort();
1271
- }
1272
- pendingRequests[port] = ajax.apply(this, arguments);
1273
- return pendingRequests[port];
1331
+ pendingRequests[port] = xhr;
1332
+ }
1333
+ });
1334
+ } else {
1335
+ // Proxy ajax
1336
+ ajax = $.ajax;
1337
+ $.ajax = function( settings ) {
1338
+ var mode = ( "mode" in settings ? settings : $.ajaxSettings ).mode,
1339
+ port = ( "port" in settings ? settings : $.ajaxSettings ).port;
1340
+ if ( mode === "abort" ) {
1341
+ if ( pendingRequests[port] ) {
1342
+ pendingRequests[port].abort();
1274
1343
  }
1275
- return ajax.apply(this, arguments);
1276
- };
1277
- }
1278
- }(jQuery));
1344
+ pendingRequests[port] = ajax.apply(this, arguments);
1345
+ return pendingRequests[port];
1346
+ }
1347
+ return ajax.apply(this, arguments);
1348
+ };
1349
+ }
1279
1350
 
1280
1351
  // provides delegate(type: String, delegate: Selector, handler: Callback) plugin for easier event delegation
1281
1352
  // handler is only called when $(event.target).is(delegate), in the scope of the jquery-object for event.target
1282
- (function($) {
1283
- $.extend($.fn, {
1284
- validateDelegate: function( delegate, type, handler ) {
1285
- return this.bind(type, function( event ) {
1286
- var target = $(event.target);
1287
- if ( target.is(delegate) ) {
1288
- return handler.apply(target, arguments);
1289
- }
1290
- });
1291
- }
1292
- });
1293
- }(jQuery));
1353
+
1354
+ $.extend($.fn, {
1355
+ validateDelegate: function( delegate, type, handler ) {
1356
+ return this.bind(type, function( event ) {
1357
+ var target = $(event.target);
1358
+ if ( target.is(delegate) ) {
1359
+ return handler.apply(target, arguments);
1360
+ }
1361
+ });
1362
+ }
1363
+ });
1364
+
1365
+ }));