PageSourceSearch

https://efsewi.org/library/assets/js/jquery.validate.js

js efsewi.org collected 2026-10-02 02:04:18 UTC 46,285 bytes, 1,552 lines download raw bytes

vendor: 44,080 bytes, lines 1-1474
1/*!
2
3 * jQuery Validation Plugin v1.15.0
4
5 *
6
7 * http://jqueryvalidation.org/
8
9 *
10
11 * Copyright (c) 2016 Jörn Zaefferer
12
13 * Released under the MIT license
14
15 */
16
17(function( factory ) {
18
19	if ( typeof define === "function" && define.amd ) {
20
21		define( ["jquery"], factory );
22
23	} else if (typeof module === "object" && module.exports) {
24
25		module.exports = factory( require( "jquery" ) );
26
27	} else {
28
29		factory( jQuery );
30
31	}
32
33}(function( $ ) {
34
35
36
37$.extend( $.fn, {
38
39	// http://jqueryvalidation.org/validate/
40	validate: function( options ) {
41
42		// If nothing is selected, return nothing; can't chain anyway
43		if ( !this.length ) {
44			if ( options && options.debug && window.console ) {
45				console.warn( "Nothing selected, can't validate, returning nothing." );
46			}
47			return;
48		}
49
50		// Check if a validator for this form was already created
51		var validator = $.data( this[ 0 ], "validator" );
52		if ( validator ) {
53			return validator;
54		}
55
56		// Add novalidate tag if HTML5.
57		this.attr( "novalidate", "novalidate" );
58
59		validator = new $.validator( options, this[ 0 ] );
60		$.data( this[ 0 ], "validator", validator );
61
62		if ( validator.settings.onsubmit ) {
63
64			this.on( "click.validate", ":submit", function( event ) {
65				if ( validator.settings.submitHandler ) {
66					validator.submitButton = event.target;
67				}
68
69				// Allow suppressing validation by adding a cancel class to the submit button
70				if ( $( this ).hasClass( "cancel" ) ) {
71					validator.cancelSubmit = true;
72				}
73
74				// Allow suppressing validation by adding the html5 formnovalidate attribute to the submit button
75				if ( $( this ).attr( "formnovalidate" ) !== undefined ) {
76					validator.cancelSubmit = true;
77				}
78			} );
79
80			// Validate the form on submit
81			this.on( "submit.validate", function( event ) {
82				if ( validator.settings.debug ) {
83
84					// Prevent form submit to be able to see console output
85					event.preventDefault();
86				}
87				function handle() {
88					var hidden, result;
89					if ( validator.settings.submitHandler ) {
90						if ( validator.submitButton ) {
91
92							// Insert a hidden input as a replacement for the missing submit button
93							hidden = $( "<input type='hidden'/>" )
94								.attr( "name", validator.submitButton.name )
95								.val( $( validator.submitButton ).val() )
96								.appendTo( validator.currentForm );
97						}
98						result = validator.settings.submitHandler.call( validator, validator.currentForm, event );
99						if ( validator.submitButton ) {
100
101							// And clean up afterwards; thanks to no-block-scope, hidden can be referenced
102							hidden.remove();
103						}
104						if ( result !== undefined ) {
105							return result;
106						}
107						return false;
108					}
109					return true;
110				}
111
112				// Prevent submit for invalid forms or custom submit handlers
113				if ( validator.cancelSubmit ) {
114					validator.cancelSubmit = false;
115					return handle();
116				}
117				if ( validator.form() ) {
118					if ( validator.pendingRequest ) {
119						validator.formSubmitted = true;
120						return false;
121					}
122					return handle();
123				} else {
124					validator.focusInvalid();
125					return false;
126				}
127			} );
128		}
129
130		return validator;
131	},
132
133	// http://jqueryvalidation.org/valid/
134	valid: function() {
135		var valid, validator, errorList;
136
137		if ( $( this[ 0 ] ).is( "form" ) ) {
138			valid = this.validate().form();
139		} else {
140			errorList = [];
141			valid = true;
142			validator = $( this[ 0 ].form ).validate();
143			this.each( function() {
144				valid = validator.element( this ) && valid;
145				if ( !valid ) {
146					errorList = errorList.concat( validator.errorList );
147				}
148			} );
149			validator.errorList = errorList;
150		}
151		return valid;
152	},
153
154	// http://jqueryvalidation.org/rules/
155	rules: function( command, argument ) {
156
157		// If nothing is selected, return nothing; can't chain anyway
158		if ( !this.length ) {
159			return;
160		}
161
162		var element = this[ 0 ],
163			settings, staticRules, existingRules, data, param, filtered;
164
165		if ( command ) {
166			settings = $.data( element.form, "validator" ).settings;
167			staticRules = settings.rules;
168			existingRules = $.validator.staticRules( element );
169			switch ( command ) {
170			case "add":
171				$.extend( existingRules, $.validator.normalizeRule( argument ) );
172
173				// Remove messages from rules, but allow them to be set separately
174				delete existingRules.messages;
175				staticRules[ element.name ] = existingRules;
176				if ( argument.messages ) {
177					settings.messages[ element.name ] = $.extend( settings.messages[ element.name ], argument.messages );
178				}
179				break;
180			case "remove":
181				if ( !argument ) {
182					delete staticRules[ element.name ];
183					return existingRules;
184				}
185				filtered = {};
186				$.each( argument.split( /\s/ ), function( index, method ) {
187					filtered[ method ] = existingRules[ method ];
188					delete existingRules[ method ];
189					if ( method === "required" ) {
190						$( element ).removeAttr( "aria-required" );
191					}
192				} );
193				return filtered;
194			}
195		}
196
197		data = $.validator.normalizeRules(
198		$.extend(
199			{},
200			$.validator.classRules( element ),
201			$.validator.attributeRules( element ),
202			$.validator.dataRules( element ),
203			$.validator.staticRules( element )
204		), element );
205
206		// Make sure required is at front
207		if ( data.required ) {
208			param = data.required;
209			delete data.required;
210			data = $.extend( { required: param }, data );
211			$( element ).attr( "aria-required", "true" );
212		}
213
214		// Make sure remote is at back
215		if ( data.remote ) {
216			param = data.remote;
217			delete data.remote;
218			data = $.extend( data, { remote: param } );
219		}
220
221		return data;
222	}
223} );
224
225// Custom selectors
226$.extend( $.expr[ ":" ], {
227
228	// http://jqueryvalidation.org/blank-selector/
229	blank: function( a ) {
230		return !$.trim( "" + $( a ).val() );
231	},
232
233	// http://jqueryvalidation.org/filled-selector/
234	filled: function( a ) {
235		var val = $( a ).val();
236		return val !== null && !!$.trim( "" + val );
237	},
238
239	// http://jqueryvalidation.org/unchecked-selector/
240	unchecked: function( a ) {
241		return !$( a ).prop( "checked" );
242	}
243} );
244
245// Constructor for validator
246$.validator = function( options, form ) {
247	this.settings = $.extend( true, {}, $.validator.defaults, options );
248	this.currentForm = form;
249	this.init();
250};
251
252// http://jqueryvalidation.org/jQuery.validator.format/
253$.validator.format = function( source, params ) {
254	if ( arguments.length === 1 ) {
255		return function() {
256			var args = $.makeArray( arguments );
257			args.unshift( source );
258			return $.validator.format.apply( this, args );
259		};
260	}
261	if ( params === undefined ) {
262		return source;
263	}
264	if ( arguments.length > 2 && params.constructor !== Array  ) {
265		params = $.makeArray( arguments ).slice( 1 );
266	}
267	if ( params.constructor !== Array ) {
268		params = [ params ];
269	}
270	$.each( params, function( i, n ) {
271		source = source.replace( new RegExp( "\\{" + i + "\\}", "g" ), function() {
272			return n;
273		} );
274	} );
275	return source;
276};
277
278$.extend( $.validator, {
279
280	defaults: {
281		messages: {},
282		groups: {},
283		rules: {},
284		errorClass: "error",
285		pendingClass: "pending",
286		validClass: "valid",
287		errorElement: "label",
288		focusCleanup: false,
289		focusInvalid: true,
290		errorContainer: $( [] ),
291		errorLabelContainer: $( [] ),
292		onsubmit: true,
293		ignore: ":hidden",
294		ignoreTitle: false,
295		onfocusin: function( element ) {
296			this.lastActive = element;
297
298			// Hide error label and remove error class on focus if enabled
299			if ( this.settings.focusCleanup ) {
300				if ( this.settings.unhighlight ) {
301					this.settings.unhighlight.call( this, element, this.settings.errorClass, this.settings.validClass );
302				}
303				this.hideThese( this.errorsFor( element ) );
304			}
305		},
306		onfocusout: function( element ) {
307			if ( !this.checkable( element ) && ( element.name in this.submitted || !this.optional( element ) ) ) {
308				this.element( element );
309			}
310		},
311		onkeyup: function( element, event ) {
312
313			// Avoid revalidate the field when pressing one of the following keys
314			// Shift       => 16
315			// Ctrl        => 17
316			// Alt         => 18
317			// Caps lock   => 20
318			// End         => 35
319			// Home        => 36
320			// Left arrow  => 37
321			// Up arrow    => 38
322			// Right arrow => 39
323			// Down arrow  => 40
324			// Insert      => 45
325			// Num lock    => 144
326			// AltGr key   => 225
327			var excludedKeys = [
328				16, 17, 18, 20, 35, 36, 37,
329				38, 39, 40, 45, 144, 225
330			];
331
332			if ( event.which === 9 && this.elementValue( element ) === "" || $.inArray( event.keyCode, excludedKeys ) !== -1 ) {
333				return;
334			} else if ( element.name in this.submitted || element.name in this.invalid ) {
335				this.element( element );
336			}
337		},
338		onclick: function( element ) {
339
340			// Click on selects, radiobuttons and checkboxes
341			if ( element.name in this.submitted ) {
342				this.element( element );
343
344			// Or option elements, check parent select in that case
345			} else if ( element.parentNode.name in this.submitted ) {
346				this.element( element.parentNode );
347			}
348		},
349		highlight: function( element, errorClass, validClass ) {
350			if ( element.type === "radio" ) {
351				this.findByName( element.name ).addClass( errorClass ).removeClass( validClass );
352			} else {
353				$( element ).addClass( errorClass ).removeClass( validClass );
354			}
355		},
356		unhighlight: function( element, errorClass, validClass ) {
357			if ( element.type === "radio" ) {
358				this.findByName( element.name ).removeClass( errorClass ).addClass( validClass );
359			} else {
360				$( element ).removeClass( errorClass ).addClass( validClass );
361			}
362		}
363	},
364
365	// http://jqueryvalidation.org/jQuery.validator.setDefaults/
366	setDefaults: function( settings ) {
367		$.extend( $.validator.defaults, settings );
368	},
369
370	messages: {
371		required: "This field is required.",
372		remote: "Please fix this field.",
373		email: "Please enter a valid email address.",
374		url: "Please enter a valid URL.",
375		date: "Please enter a valid date.",
376		dateISO: "Please enter a valid date ( ISO ).",
377		number: "Please enter a valid number.",
378		digits: "Please enter only digits.",
379		equalTo: "Please enter the same value again.",
380		maxlength: $.validator.format( "Please enter no more than {0} characters." ),
381		minlength: $.validator.format( "Please enter at least {0} characters." ),
382		rangelength: $.validator.format( "Please enter a value between {0} and {1} characters long." ),
383		range: $.validator.format( "Please enter a value between {0} and {1}." ),
384		max: $.validator.format( "Please enter a value less than or equal to {0}." ),
385		min: $.validator.format( "Please enter a value greater than or equal to {0}." ),
386		step: $.validator.format( "Please enter a multiple of {0}." )
387	},
388
389	autoCreateRanges: false,
390
391	prototype: {
392
393		init: function() {
394			this.labelContainer = $( this.settings.errorLabelContainer );
395			this.errorContext = this.labelContainer.length && this.labelContainer || $( this.currentForm );
396			this.containers = $( this.settings.errorContainer ).add( this.settings.errorLabelContainer );
397			this.submitted = {};
398			this.valueCache = {};
399			this.pendingRequest = 0;
400			this.pending = {};
401			this.invalid = {};
402			this.reset();
403
404			var groups = ( this.groups = {} ),
405				rules;
406			$.each( this.settings.groups, function( key, value ) {
407				if ( typeof value === "string" ) {
408					value = value.split( /\s/ );
409				}
410				$.each( value, function( index, name ) {
411					groups[ name ] = key;
412				} );
413			} );
414			rules = this.settings.rules;
415			$.each( rules, function( key, value ) {
416				rules[ key ] = $.validator.normalizeRule( value );
417			} );
418
419			function delegate( event ) {
420				var validator = $.data( this.form, "validator" ),
421					eventType = "on" + event.type.replace( /^validate/, "" ),
422					settings = validator.settings;
423				if ( settings[ eventType ] && !$( this ).is( settings.ignore ) ) {
424					settings[ eventType ].call( validator, this, event );
425				}
426			}
427
428			$( this.currentForm )
429				.on( "focusin.validate focusout.validate keyup.validate",
430					":text, [type='password'], [type='file'], select, textarea, [type='number'], [type='search'], " +
431					"[type='tel'], [type='url'], [type='email'], [type='datetime'], [type='date'], [type='month'], " +
432					"[type='week'], [type='time'], [type='datetime-local'], [type='range'], [type='color'], " +
433					"[type='radio'], [type='checkbox'], [contenteditable]", delegate )
434
435				// Support: Chrome, oldIE
436				// "select" is provided as event.target when clicking a option
437				.on( "click.validate", "select, option, [type='radio'], [type='checkbox']", delegate );
438
439			if ( this.settings.invalidHandler ) {
440				$( this.currentForm ).on( "invalid-form.validate", this.settings.invalidHandler );
441			}
442
443			// Add aria-required to any Static/Data/Class required fields before first validation
444			// Screen readers require this attribute to be present before the initial submission http://www.w3.org/TR/WCAG-TECHS/ARIA2.html
445			$( this.currentForm ).find( "[required], [data-rule-required], .required" ).attr( "aria-required", "true" );
446		},
447
448		// http://jqueryvalidation.org/Validator.form/
449		form: function() {
450			this.checkForm();
451			$.extend( this.submitted, this.errorMap );
452			this.invalid = $.extend( {}, this.errorMap );
453			if ( !this.valid() ) {
454				$( this.currentForm ).triggerHandler( "invalid-form", [ this ] );
455			}
456			this.showErrors();
457			return this.valid();
458		},
459
460		checkForm: function() {
461			this.prepareForm();
462			for ( var i = 0, elements = ( this.currentElements = this.elements() ); elements[ i ]; i++ ) {
463				this.check( elements[ i ] );
464			}
465			return this.valid();
466		},
467
468		// http://jqueryvalidation.org/Validator.element/
469		element: function( element ) {
470			var cleanElement = this.clean( element ),
471				checkElement = this.validationTargetFor( cleanElement ),
472				v = this,
473				result = true,
474				rs, group;
475
476			if ( checkElement === undefined ) {
477				delete this.invalid[ cleanElement.name ];
478			} else {
479				this.prepareElement( checkElement );
480				this.currentElements = $( checkElement );
481
482				// If this element is grouped, then validate all group elements already
483				// containing a value
484				group = this.groups[ checkElement.name ];
485				if ( group ) {
486					$.each( this.groups, function( name, testgroup ) {
487						if ( testgroup === group && name !== checkElement.name ) {
488							cleanElement = v.validationTargetFor( v.clean( v.findByName( name ) ) );
489							if ( cleanElement && cleanElement.name in v.invalid ) {
490								v.currentElements.push( cleanElement );
491								result = result && v.check( cleanElement );
492							}
493						}
494					} );
495				}
496
497				rs = this.check( checkElement ) !== false;
498				result = result && rs;
499				if ( rs ) {
500					this.invalid[ checkElement.name ] = false;
501				} else {
502					this.invalid[ checkElement.name ] = true;
503				}
504
505				if ( !this.numberOfInvalids() ) {
506
507					// Hide error containers on last error
508					this.toHide = this.toHide.add( this.containers );
509				}
510				this.showErrors();
511
512				// Add aria-invalid status for screen readers
513				$( element ).attr( "aria-invalid", !rs );
514			}
515
516			return result;
517		},
518
519		// http://jqueryvalidation.org/Validator.showErrors/
520		showErrors: function( errors ) {
521			if ( errors ) {
522				var validator = this;
523
524				// Add items to error list and map
525				$.extend( this.errorMap, errors );
526				this.errorList = $.map( this.errorMap, function( message, name ) {
527					return {
528						message: message,
529						element: validator.findByName( name )[ 0 ]
530					};
531				} );
532
533				// Remove items from success list
534				this.successList = $.grep( this.successList, function( element ) {
535					return !( element.name in errors );
536				} );
537			}
538			if ( this.settings.showErrors ) {
539				this.settings.showErrors.call( this, this.errorMap, this.errorList );
540			} else {
541				this.defaultShowErrors();
542			}
543		},
544
545		// http://jqueryvalidation.org/Validator.resetForm/
546		resetForm: function() {
547			if ( $.fn.resetForm ) {
548				$( this.currentForm ).resetForm();
549			}
550			this.invalid = {};
551			this.submitted = {};
552			this.prepareForm();
553			this.hideErrors();
554			var elements = this.elements()
555				.removeData( "previousValue" )
556				.removeAttr( "aria-invalid" );
557
558			this.resetElements( elements );
559		},
560
561		resetElements: function( elements ) {
562			var i;
563
564			if ( this.settings.unhighlight ) {
565				for ( i = 0; elements[ i ]; i++ ) {
566					this.settings.unhighlight.call( this, elements[ i ],
567						this.settings.errorClass, "" );
568					this.findByName( elements[ i ].name ).removeClass( this.settings.validClass );
569				}
570			} else {
571				elements
572					.removeClass( this.settings.errorClass )
573					.removeClass( this.settings.validClass );
574			}
575		},
576
577		numberOfInvalids: function() {
578			return this.objectLength( this.invalid );
579		},
580
581		objectLength: function( obj ) {
582			/* jshint unused: false */
583			var count = 0,
584				i;
585			for ( i in obj ) {
586				if ( obj[ i ] ) {
587					count++;
588				}
589			}
590			return count;
591		},
592
593		hideErrors: function() {
594			this.hideThese( this.toHide );
595		},
596
597		hideThese: function( errors ) {
598			errors.not( this.containers ).text( "" );
599			this.addWrapper( errors ).hide();
600		},
601
602		valid: function() {
603			return this.size() === 0;
604		},
605
606		size: function() {
607			return this.errorList.length;
608		},
609
610		focusInvalid: function() {
611			if ( this.settings.focusInvalid ) {
612				try {
613					$( this.findLastActive() || this.errorList.length && this.errorList[ 0 ].element || [] )
614					.filter( ":visible" )
615					.focus()
616
617					// Manually trigger focusin event; without it, focusin handler isn't called, findLastActive won't have anything to find
618					.trigger( "focusin" );
619				} catch ( e ) {
620
621					// Ignore IE throwing errors when focusing hidden elements
622				}
623			}
624		},
625
626		findLastActive: function() {
627			var lastActive = this.lastActive;
628			return lastActive && $.grep( this.errorList, function( n ) {
629				return n.element.name === lastActive.name;
630			} ).length === 1 && lastActive;
631		},
632
633		elements: function() {
634			var validator = this,
635				rulesCache = {};
636
637			// Select all valid inputs inside the form (no submit or reset buttons)
638			return $( this.currentForm )
639			.find( "input, select, textarea, [contenteditable]" )
640			.not( ":submit, :reset, :image, :disabled" )
641			.not( this.settings.ignore )
642			.filter( function() {
643				var name = this.name || $( this ).attr( "name" ); // For contenteditable
644				if ( !name && validator.settings.debug && window.console ) {
645					console.error( "%o has no name assigned", this );
646				}
647
648				// Set form expando on contenteditable
649				if ( this.hasAttribute( "contenteditable" ) ) {
650					this.form = $( this ).closest( "form" )[ 0 ];
651				}
652
653				// Select only the first element for each name, and only those with rules specified
654				if ( name in rulesCache || !validator.objectLength( $( this ).rules() ) ) {
655					return false;
656				}
657
658				rulesCache[ name ] = true;
659				return true;
660			} );
661		},
662
663		clean: function( selector ) {
664			return $( selector )[ 0 ];
665		},
666
667		errors: function() {
668			var errorClass = this.settings.errorClass.split( " " ).join( "." );
669			return $( this.settings.errorElement + "." + errorClass, this.errorContext );
670		},
671
672		resetInternals: function() {
673			this.successList = [];
674			this.errorList = [];
675			this.errorMap = {};
676			this.toShow = $( [] );
677			this.toHide = $( [] );
678		},
679
680		reset: function() {
681			this.resetInternals();
682			this.currentElements = $( [] );
683		},
684
685		prepareForm: function() {
686			this.reset();
687			this.toHide = this.errors().add( this.containers );
688		},
689
690		prepareElement: function( element ) {
691			this.reset();
692			this.toHide = this.errorsFor( element );
693		},
694
695		elementValue: function( element ) {
696			var $element = $( element ),
697				type = element.type,
698				val, idx;
699
700			if ( type === "radio" || type === "checkbox" ) {
701				return this.findByName( element.name ).filter( ":checked" ).val();
702			} else if ( type === "number" && typeof element.validity !== "undefined" ) {
703				return element.validity.badInput ? "NaN" : $element.val();
704			}
705
706			if ( element.hasAttribute( "contenteditable" ) ) {
707				val = $element.text();
708			} else {
709				val = $element.val();
710			}
711
712			if ( type === "file" ) {
713
714				// Modern browser (chrome & safari)
715				if ( val.substr( 0, 12 ) === "C:\\fakepath\\" ) {
716					return val.substr( 12 );
717				}
718
719				// Legacy browsers
720				// Unix-based path
721				idx = val.lastIndexOf( "/" );
722				if ( idx >= 0 ) {
723					return val.substr( idx + 1 );
724				}
725
726				// Windows-based path
727				idx = val.lastIndexOf( "\\" );
728				if ( idx >= 0 ) {
729					return val.substr( idx + 1 );
730				}
731
732				// Just the file name
733				return val;
734			}
735
736			if ( typeof val === "string" ) {
737				return val.replace( /\r/g, "" );
738			}
739			return val;
740		},
741
742		check: function( element ) {
743			element = this.validationTargetFor( this.clean( element ) );
744
745			var rules = $( element ).rules(),
746				rulesCount = $.map( rules, function( n, i ) {
747					return i;
748				} ).length,
749				dependencyMismatch = false,
750				val = this.elementValue( element ),
751				result, method, rule;
752
753			// If a normalizer is defined for this element, then
754			// call it to retreive the changed value instead
755			// of using the real one.
756			// Note that `this` in the normalizer is `element`.
757			if ( typeof rules.normalizer === "function" ) {
758				val = rules.normalizer.call( element, val );
759
760				if ( typeof val !== "string" ) {
761					throw new TypeError( "The normalizer should return a string value." );
762				}
763
764				// Delete the normalizer from rules to avoid treating
765				// it as a pre-defined method.
766				delete rules.normalizer;
767			}
768
769			for ( method in rules ) {
770				rule = { method: method, parameters: rules[ method ] };
771				try {
772					result = $.validator.methods[ method ].call( this, val, element, rule.parameters );
773
774					// If a method indicates that the field is optional and therefore valid,
775					// don't mark it as valid when there are no other rules
776					if ( result === "dependency-mismatch" && rulesCount === 1 ) {
777						dependencyMismatch = true;
778						continue;
779					}
780					dependencyMismatch = false;
781
782					if ( result === "pending" ) {
783						this.toHide = this.toHide.not( this.errorsFor( element ) );
784						return;
785					}
786
787					if ( !result ) {
788						this.formatAndAdd( element, rule );
789						return false;
790					}
791				} catch ( e ) {
792					if ( this.settings.debug && window.console ) {
793						console.log( "Exception occurred when checking element " + element.id + ", check the '" + rule.method + "' method.", e );
794					}
795					if ( e instanceof TypeError ) {
796						e.message += ".  Exception occurred when checking element " + element.id + ", check the '" + rule.method + "' method.";
797					}
798
799					throw e;
800				}
801			}
802			if ( dependencyMismatch ) {
803				return;
804			}
805			if ( this.objectLength( rules ) ) {
806				this.successList.push( element );
807			}
808			return true;
809		},
810
811		// Return the custom message for the given element and validation method
812		// specified in the element's HTML5 data attribute
813		// return the generic message if present and no method specific message is present
814		customDataMessage: function( element, method ) {
815			return $( element ).data( "msg" + method.charAt( 0 ).toUpperCase() +
816				method.substring( 1 ).toLowerCase() ) || $( element ).data( "msg" );
817		},
818
819		// Return the custom message for the given element name and validation method
820		customMessage: function( name, method ) {
821			var m = this.settings.messages[ name ];
822			return m && ( m.constructor === String ? m : m[ method ] );
823		},
824
825		// Return the first defined argument, allowing empty strings
826		findDefined: function() {
827			for ( var i = 0; i < arguments.length; i++ ) {
828				if ( arguments[ i ] !== undefined ) {
829					return arguments[ i ];
830				}
831			}
832			return undefined;
833		},
834
835		defaultMessage: function( element, rule ) {
836			var message = this.findDefined(
837					this.customMessage( element.name, rule.method ),
838					this.customDataMessage( element, rule.method ),
839
840					// 'title' is never undefined, so handle empty string as undefined
841					!this.settings.ignoreTitle && element.title || undefined,
842					$.validator.messages[ rule.method ],
843					"<strong>Warning: No message defined for " + element.name + "</strong>"
844				),
845				theregex = /\$?\{(\d+)\}/g;
846			if ( typeof message === "function" ) {
847				message = message.call( this, rule.parameters, element );
848			} else if ( theregex.test( message ) ) {
849				message = $.validator.format( message.replace( theregex, "{$1}" ), rule.parameters );
850			}
851
852			return message;
853		},
854
855		formatAndAdd: function( element, rule ) {
856			var message = this.defaultMessage( element, rule );
857
858			this.errorList.push( {
859				message: message,
860				element: element,
861				method: rule.method
862			} );
863
864			this.errorMap[ element.name ] = message;
865			this.submitted[ element.name ] = message;
866		},
867
868		addWrapper: function( toToggle ) {
869			if ( this.settings.wrapper ) {
870				toToggle = toToggle.add( toToggle.parent( this.settings.wrapper ) );
871			}
872			return toToggle;
873		},
874
875		defaultShowErrors: function() {
876			var i, elements, error;
877			for ( i = 0; this.errorList[ i ]; i++ ) {
878				error = this.errorList[ i ];
879				if ( this.settings.highlight ) {
880					this.settings.highlight.call( this, error.element, this.settings.errorClass, this.settings.validClass );
881				}
882				this.showLabel( error.element, error.message );
883			}
884			if ( this.errorList.length ) {
885				this.toShow = this.toShow.add( this.containers );
886			}
887			if ( this.settings.success ) {
888				for ( i = 0; this.successList[ i ]; i++ ) {
889					this.showLabel( this.successList[ i ] );
890				}
891			}
892			if ( this.settings.unhighlight ) {
893				for ( i = 0, elements = this.validElements(); elements[ i ]; i++ ) {
894					this.settings.unhighlight.call( this, elements[ i ], this.settings.errorClass, this.settings.validClass );
895				}
896			}
897			this.toHide = this.toHide.not( this.toShow );
898			this.hideErrors();
899			this.addWrapper( this.toShow ).show();
900		},
901
902		validElements: function() {
903			return this.currentElements.not( this.invalidElements() );
904		},
905
906		invalidElements: function() {
907			return $( this.errorList ).map( function() {
908				return this.element;
909			} );
910		},
911
912		showLabel: function( element, message ) {
913			var place, group, errorID, v,
914				error = this.errorsFor( element ),
915				elementID = this.idOrName( element ),
916				describedBy = $( element ).attr( "aria-describedby" );
917
918			if ( error.length ) {
919
920				// Refresh error/success class
921				error.removeClass( this.settings.validClass ).addClass( this.settings.errorClass );
922
923				// Replace message on existing label
924				error.html( message );
925			} else {
926
927				// Create error element
928				error = $( "<" + this.settings.errorElement + ">" )
929					.attr( "id", elementID + "-error" )
930					.addClass( this.settings.errorClass )
931					.html( message || "" );
932
933				// Maintain reference to the element to be placed into the DOM
934				place = error;
935				if ( this.settings.wrapper ) {
936
937					// Make sure the element is visible, even in IE
938					// actually showing the wrapped element is handled elsewhere
939					place = error.hide().show().wrap( "<" + this.settings.wrapper + "/>" ).parent();
940				}
941				if ( this.labelContainer.length ) {
942					this.labelContainer.append( place );
943				} else if ( this.settings.errorPlacement ) {
944					this.settings.errorPlacement( place, $( element ) );
945				} else {
946					place.insertAfter( element );
947				}
948
949				// Link error back to the element
950				if ( error.is( "label" ) ) {
951
952					// If the error is a label, then associate using 'for'
953					error.attr( "for", elementID );
954
955					// If the element is not a child of an associated label, then it's necessary
956					// to explicitly apply aria-describedby
957				} else if ( error.parents( "label[for='" + this.escapeCssMeta( elementID ) + "']" ).length === 0 ) {
958					errorID = error.attr( "id" );
959
960					// Respect existing non-error aria-describedby
961					if ( !describedBy ) {
962						describedBy = errorID;
963					} else if ( !describedBy.match( new RegExp( "\\b" + this.escapeCssMeta( errorID ) + "\\b" ) ) ) {
964
965						// Add to end of list if not already present
966						describedBy += " " + errorID;
967					}
968					$( element ).attr( "aria-describedby", describedBy );
969
970					// If this element is grouped, then assign to all elements in the same group
971					group = this.groups[ element.name ];
972					if ( group ) {
973						v = this;
974						$.each( v.groups, function( name, testgroup ) {
975							if ( testgroup === group ) {
976								$( "[name='" + v.escapeCssMeta( name ) + "']", v.currentForm )
977									.attr( "aria-describedby", error.attr( "id" ) );
978							}
979						} );
980					}
981				}
982			}
983			if ( !message && this.settings.success ) {
984				error.text( "" );
985				if ( typeof this.settings.success === "string" ) {
986					error.addClass( this.settings.success );
987				} else {
988					this.settings.success( error, element );
989				}
990			}
991			this.toShow = this.toShow.add( error );
992		},
993
994		errorsFor: function( element ) {
995			var name = this.escapeCssMeta( this.idOrName( element ) ),
996				describer = $( element ).attr( "aria-describedby" ),
997				selector = "label[for='" + name + "'], label[for='" + name + "'] *";
998
999			// 'aria-describedby' should directly reference the error element
1000			if ( describer ) {
1001				selector = selector + ", #" + this.escapeCssMeta( describer )
1002					.replace( /\s+/g, ", #" );
1003			}
1004
1005			return this
1006				.errors()
1007				.filter( selector );
1008		},
1009
1010		// See https://api.jquery.com/category/selectors/, for CSS
1011		// meta-characters that should be escaped in order to be used with JQuery
1012		// as a literal part of a name/id or any selector.
1013		escapeCssMeta: function( string ) {
1014			return string.replace( /([\\!"#$%&'()*+,./:;<=>?@\[\]^`{|}~])/g, "\\$1" );
1015		},
1016
1017		idOrName: function( element ) {
1018			return this.groups[ element.name ] || ( this.checkable( element ) ? element.name : element.id || element.name );
1019		},
1020
1021		validationTargetFor: function( element ) {
1022
1023			// If radio/checkbox, validate first element in group instead
1024			if ( this.checkable( element ) ) {
1025				element = this.findByName( element.name );
1026			}
1027
1028			// Always apply ignore filter
1029			return $( element ).not( this.settings.ignore )[ 0 ];
1030		},
1031
1032		checkable: function( element ) {
1033			return ( /radio|checkbox/i ).test( element.type );
1034		},
1035
1036		findByName: function( name ) {
1037			return $( this.currentForm ).find( "[name='" + this.escapeCssMeta( name ) + "']" );
1038		},
1039
1040		getLength: function( value, element ) {
1041			switch ( element.nodeName.toLowerCase() ) {
1042			case "select":
1043				return $( "option:selected", element ).length;
1044			case "input":
1045				if ( this.checkable( element ) ) {
1046					return this.findByName( element.name ).filter( ":checked" ).length;
1047				}
1048			}
1049			return value.length;
1050		},
1051
1052		depend: function( param, element ) {
1053			return this.dependTypes[ typeof param ] ? this.dependTypes[ typeof param ]( param, element ) : true;
1054		},
1055
1056		dependTypes: {
1057			"boolean": function( param ) {
1058				return param;
1059			},
1060			"string": function( param, element ) {
1061				return !!$( param, element.form ).length;
1062			},
1063			"function": function( param, element ) {
1064				return param( element );
1065			}
1066		},
1067
1068		optional: function( element ) {
1069			var val = this.elementValue( element );
1070			return !$.validator.methods.required.call( this, val, element ) && "dependency-mismatch";
1071		},
1072
1073		startRequest: function( element ) {
1074			if ( !this.pending[ element.name ] ) {
1075				this.pendingRequest++;
1076				$( element ).addClass( this.settings.pendingClass );
1077				this.pending[ element.name ] = true;
1078			}
1079		},
1080
1081		stopRequest: function( element, valid ) {
1082			this.pendingRequest--;
1083
1084			// Sometimes synchronization fails, make sure pendingRequest is never < 0
1085			if ( this.pendingRequest < 0 ) {
1086				this.pendingRequest = 0;
1087			}
1088			delete this.pending[ element.name ];
1089			$( element ).removeClass( this.settings.pendingClass );
1090			if ( valid && this.pendingRequest === 0 && this.formSubmitted && this.form() ) {
1091				$( this.currentForm ).submit();
1092				this.formSubmitted = false;
1093			} else if ( !valid && this.pendingRequest === 0 && this.formSubmitted ) {
1094				$( this.currentForm ).triggerHandler( "invalid-form", [ this ] );
1095				this.formSubmitted = false;
1096			}
1097		},
1098
1099		previousValue: function( element, method ) {
1100			return $.data( element, "previousValue" ) || $.data( element, "previousValue", {
1101				old: null,
1102				valid: true,
1103				message: this.defaultMessage( element, { method: method } )
1104			} );
1105		},
1106
1107		// Cleans up all forms and elements, removes validator-specific events
1108		destroy: function() {
1109			this.resetForm();
1110
1111			$( this.currentForm )
1112				.off( ".validate" )
1113				.removeData( "validator" )
1114				.find( ".validate-equalTo-blur" )
1115					.off( ".validate-equalTo" )
1116					.removeClass( "validate-equalTo-blur" );
1117		}
1118
1119	},
1120
1121	classRuleSettings: {
1122		required: { required: true },
1123		email: { email: true },
1124		url: { url: true },
1125		date: { date: true },
1126		dateISO: { dateISO: true },
1127		number: { number: true },
1128		digits: { digits: true },
1129		creditcard: { creditcard: true }
1130	},
1131
1132	addClassRules: function( className, rules ) {
1133		if ( className.constructor === String ) {
1134			this.classRuleSettings[ className ] = rules;
1135		} else {
1136			$.extend( this.classRuleSettings, className );
1137		}
1138	},
1139
1140	classRules: function( element ) {
1141		var rules = {},
1142			classes = $( element ).attr( "class" );
1143
1144		if ( classes ) {
1145			$.each( classes.split( " " ), function() {
1146				if ( this in $.validator.classRuleSettings ) {
1147					$.extend( rules, $.validator.classRuleSettings[ this ] );
1148				}
1149			} );
1150		}
1151		return rules;
1152	},
1153
1154	normalizeAttributeRule: function( rules, type, method, value ) {
1155
1156		// Convert the value to a number for number inputs, and for text for backwards compability
1157		// allows type="date" and others to be compared as strings
1158		if ( /min|max|step/.test( method ) && ( type === null || /number|range|text/.test( type ) ) ) {
1159			value = Number( value );
1160
1161			// Support Opera Mini, which returns NaN for undefined minlength
1162			if ( isNaN( value ) ) {
1163				value = undefined;
1164			}
1165		}
1166
1167		if ( value || value === 0 ) {
1168			rules[ method ] = value;
1169		} else if ( type === method && type !== "range" ) {
1170
1171			// Exception: the jquery validate 'range' method
1172			// does not test for the html5 'range' type
1173			rules[ method ] = true;
1174		}
1175	},
1176
1177	attributeRules: function( element ) {
1178		var rules = {},
1179			$element = $( element ),
1180			type = element.getAttribute( "type" ),
1181			method, value;
1182
1183		for ( method in $.validator.methods ) {
1184
1185			// Support for <input required> in both html5 and older browsers
1186			if ( method === "required" ) {
1187				value = element.getAttribute( method );
1188
1189				// Some browsers return an empty string for the required attribute
1190				// and non-HTML5 browsers might have required="" markup
1191				if ( value === "" ) {
1192					value = true;
1193				}
1194
1195				// Force non-HTML5 browsers to return bool
1196				value = !!value;
1197			} else {
1198				value = $element.attr( method );
1199			}
1200
1201			this.normalizeAttributeRule( rules, type, method, value );
1202		}
1203
1204		// 'maxlength' may be returned as -1, 2147483647 ( IE ) and 524288 ( safari ) for text inputs
1205		if ( rules.maxlength && /-1|2147483647|524288/.test( rules.maxlength ) ) {
1206			delete rules.maxlength;
1207		}
1208
1209		return rules;
1210	},
1211
1212	dataRules: function( element ) {
1213		var rules = {},
1214			$element = $( element ),
1215			type = element.getAttribute( "type" ),
1216			method, value;
1217
1218		for ( method in $.validator.methods ) {
1219			value = $element.data( "rule" + method.charAt( 0 ).toUpperCase() + method.substring( 1 ).toLowerCase() );
1220			this.normalizeAttributeRule( rules, type, method, value );
1221		}
1222		return rules;
1223	},
1224
1225	staticRules: function( element ) {
1226		var rules = {},
1227			validator = $.data( element.form, "validator" );
1228
1229		if ( validator.settings.rules ) {
1230			rules = $.validator.normalizeRule( validator.settings.rules[ element.name ] ) || {};
1231		}
1232		return rules;
1233	},
1234
1235	normalizeRules: function( rules, element ) {
1236
1237		// Handle dependency check
1238		$.each( rules, function( prop, val ) {
1239
1240			// Ignore rule when param is explicitly false, eg. required:false
1241			if ( val === false ) {
1242				delete rules[ prop ];
1243				return;
1244			}
1245			if ( val.param || val.depends ) {
1246				var keepRule = true;
1247				switch ( typeof val.depends ) {
1248				case "string":
1249					keepRule = !!$( val.depends, element.form ).length;
1250					break;
1251				case "function":
1252					keepRule = val.depends.call( element, element );
1253					break;
1254				}
1255				if ( keepRule ) {
1256					rules[ prop ] = val.param !== undefined ? val.param : true;
1257				} else {
1258					$.data( element.form, "validator" ).resetElements( $( element ) );
1259					delete rules[ prop ];
1260				}
1261			}
1262		} );
1263
1264		// Evaluate parameters
1265		$.each( rules, function( rule, parameter ) {
1266			rules[ rule ] = $.isFunction( parameter ) && rule !== "normalizer" ? parameter( element ) : parameter;
1267		} );
1268
1269		// Clean number parameters
1270		$.each( [ "minlength", "maxlength" ], function() {
1271			if ( rules[ this ] ) {
1272				rules[ this ] = Number( rules[ this ] );
1273			}
1274		} );
1275		$.each( [ "rangelength", "range" ], function() {
1276			var parts;
1277			if ( rules[ this ] ) {
1278				if ( $.isArray( rules[ this ] ) ) {
1279					rules[ this ] = [ Number( rules[ this ][ 0 ] ), Number( rules[ this ][ 1 ] ) ];
1280				} else if ( typeof rules[ this ] === "string" ) {
1281					parts = rules[ this ].replace( /[\[\]]/g, "" ).split( /[\s,]+/ );
1282					rules[ this ] = [ Number( parts[ 0 ] ), Number( parts[ 1 ] ) ];
1283				}
1284			}
1285		} );
1286
1287		if ( $.validator.autoCreateRanges ) {
1288
1289			// Auto-create ranges
1290			if ( rules.min != null && rules.max != null ) {
1291				rules.range = [ rules.min, rules.max ];
1292				delete rules.min;
1293				delete rules.max;
1294			}
1295			if ( rules.minlength != null && rules.maxlength != null ) {
1296				rules.rangelength = [ rules.minlength, rules.maxlength ];
1297				delete rules.minlength;
1298				delete rules.maxlength;
1299			}
1300		}
1301
1302		return rules;
1303	},
1304
1305	// Converts a simple string to a {string: true} rule, e.g., "required" to {required:true}
1306	normalizeRule: function( data ) {
1307		if ( typeof data === "string" ) {
1308			var transformed = {};
1309			$.each( data.split( /\s/ ), function() {
1310				transformed[ this ] = true;
1311			} );
1312			data = transformed;
1313		}
1314		return data;
1315	},
1316
1317	// http://jqueryvalidation.org/jQuery.validator.addMethod/
1318	addMethod: function( name, method, message ) {
1319		$.validator.methods[ name ] = method;
1320		$.validator.messages[ name ] = message !== undefined ? message : $.validator.messages[ name ];
1321		if ( method.length < 3 ) {
1322			$.validator.addClassRules( name, $.validator.normalizeRule( name ) );
1323		}
1324	},
1325
1326	// http://jqueryvalidation.org/jQuery.validator.methods/
1327	methods: {
1328
1329		// http://jqueryvalidation.org/required-method/
1330		required: function( value, element, param ) {
1331
1332			// Check if dependency is met
1333			if ( !this.depend( param, element ) ) {
1334				return "dependency-mismatch";
1335			}
1336			if ( element.nodeName.toLowerCase() === "select" ) {
1337
1338				// Could be an array for select-multiple or a string, both are fine this way
1339				var val = $( element ).val();
1340				return val && val.length > 0;
1341			}
1342			if ( this.checkable( element ) ) {
1343				return this.getLength( value, element ) > 0;
1344			}
1345			return value.length > 0;
1346		},
1347
1348		// http://jqueryvalidation.org/email-method/
1349		email: function( value, element ) {
1350
1351			// From https://html.spec.whatwg.org/multipage/forms.html#valid-e-mail-address
1352			// Retrieved 2014-01-14
1353			// If you have a problem with this implementation, report a bug against the above spec
1354			// Or use custom methods to implement your own email validation
1355			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 );
1356		},
1357
1358		// http://jqueryvalidation.org/url-method/
1359		url: function( value, element ) {
1360
1361			// Copyright (c) 2010-2013 Diego Perini, MIT licensed
1362			// https://gist.github.com/dperini/729294
1363			// see also https://mathiasbynens.be/demo/url-regex
1364			// modified to allow protocol-relative URLs
1365			return this.optional( element ) || /^(?:(?:(?:https?|ftp):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})).?)(?::\d{2,5})?(?:[/?#]\S*)?$/i.test( value );
1366		},
1367
1368		// http://jqueryvalidation.org/date-method/
1369		date: function( value, element ) {
1370			return this.optional( element ) || !/Invalid|NaN/.test( new Date( value ).toString() );
1371		},
1372
1373		// http://jqueryvalidation.org/dateISO-method/
1374		dateISO: function( value, element ) {
1375			return this.optional( element ) || /^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$/.test( value );
1376		},
1377
1378		// http://jqueryvalidation.org/number-method/
1379		number: function( value, element ) {
1380			return this.optional( element ) || /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/.test( value );
1381		},
1382
1383		// http://jqueryvalidation.org/digits-method/
1384		digits: function( value, element ) {
1385			return this.optional( element ) || /^\d+$/.test( value );
1386		},
1387
1388		// http://jqueryvalidation.org/minlength-method/
1389		minlength: function( value, element, param ) {
1390			var length = $.isArray( value ) ? value.length : this.getLength( value, element );
1391			return this.optional( element ) || length >= param;
1392		},
1393
1394		// http://jqueryvalidation.org/maxlength-method/
1395		maxlength: function( value, element, param ) {
1396			var length = $.isArray( value ) ? value.length : this.getLength( value, element );
1397			return this.optional( element ) || length <= param;
1398		},
1399
1400		// http://jqueryvalidation.org/rangelength-method/
1401		rangelength: function( value, element, param ) {
1402			var length = $.isArray( value ) ? value.length : this.getLength( value, element );
1403			return this.optional( element ) || ( length >= param[ 0 ] && length <= param[ 1 ] );
1404		},
1405
1406		// http://jqueryvalidation.org/min-method/
1407		min: function( value, element, param ) {
1408			return this.optional( element ) || value >= param;
1409		},
1410
1411		// http://jqueryvalidation.org/max-method/
1412		max: function( value, element, param ) {
1413			return this.optional( element ) || value <= param;
1414		},
1415
1416		// http://jqueryvalidation.org/range-method/
1417		range: function( value, element, param ) {
1418			return this.optional( element ) || ( value >= param[ 0 ] && value <= param[ 1 ] );
1419		},
1420
1421		// http://jqueryvalidation.org/step-method/
1422		step: function( value, element, param ) {
1423			var type = $( element ).attr( "type" ),
1424				errorMessage = "Step attribute on input type " + type + " is not supported.",
1425				supportedTypes = [ "text", "number", "range" ],
1426				re = new RegExp( "\\b" + type + "\\b" ),
1427				notSupported = type && !re.test( supportedTypes.join() );
1428
1429			// Works only for text, number and range input types
1430			// TODO find a way to support input types date, datetime, datetime-local, month, time and week
1431			if ( notSupported ) {
1432				throw new Error( errorMessage );
1433			}
1434			return this.optional( element ) || ( value % param === 0 );
1435		},
1436
1437		// http://jqueryvalidation.org/equalTo-method/
1438		equalTo: function( value, element, param ) {
1439
1440			// Bind to the blur event of the target in order to revalidate whenever the target field is updated
1441			var target = $( param );
1442			if ( this.settings.onfocusout && target.not( ".validate-equalTo-blur" ).length ) {
1443				target.addClass( "validate-equalTo-blur" ).on( "blur.validate-equalTo", function() {
1444					$( element ).valid();
1445				} );
1446			}
1447			return value === target.val();
1448		},
1449
1450		// http://jqueryvalidation.org/remote-method/
1451		remote: function( value, element, param, method ) {
1452			if ( this.optional( element ) ) {
1453				return "dependency-mismatch";
1454			}
1455
1456			method = typeof method === "string" && method || "remote";
1457
1458			var previous = this.previousValue( element, method ),
1459				validator, data, optionDataString;
1460
1461			if ( !this.settings.messages[ element.name ] ) {
1462				this.settings.messages[ element.name ] = {};
1463			}
1464			previous.originalMessage = previous.originalMessage || this.settings.messages[ element.name ][ method ];
1465			this.settings.messages[ element.name ][ method ] = previous.message;
1466
1467			param = typeof param === "string" && { url: param } || param;
1468			optionDataString = $.param( $.extend( { data: value }, param.data ) );
1469			if ( previous.old === optionDataString ) {
1470				return previous.valid;
1471			}
1472
1473			previous.old = optionDataString;
1474			validator = this;
1475			this.startRequest( element );
1476			data = {};
1477			data[ element.name ] = value;
1478			$.ajax( $.extend( true, {
1479				mode: "abort",
1480				port: "validate" + element.name,
1481				dataType: "json",
1482				data: data,
1483				context: validator.currentForm,
1484				success: function( response ) {
1485					var valid = response === true || response === "true",
1486						errors, message, submitted;
1487
1488					validator.settings.messages[ element.name ][ method ] = previous.originalMessage;
1489					if ( valid ) {
1490						submitted = validator.formSubmitted;
1491						validator.resetInternals();
1492						validator.toHide = validator.errorsFor( element );
1493						validator.formSubmitted = submitted;
1494						validator.successList.push( element );
1495						validator.invalid[ element.name ] = false;
1496						validator.showErrors();
1497					} else {
1498						errors = {};
1499						message = response || validator.defaultMessage( element, { method: method, parameters: value } );
1500						errors[ element.name ] = previous.message = message;
1501						validator.invalid[ element.name ] = true;
1502						validator.showErrors( errors );
1503					}
1504					previous.valid = valid;
1505					validator.stopRequest( element, valid );
1506				}
1507			}, param ) );
1508			return "pending";
1509		}
1510	}
1511
1512} );
1513
1514
1515// Ajax mode: abort
1516// usage: $.ajax({ mode: "abort"[, port: "uniqueport"]});
1517// if mode:"abort" is used, the previous request on that port (port can be undefined) is aborted via XMLHttpRequest.abort()
1518
1519var pendingRequests = {},
1520	ajax;
1521
1522// Use a prefilter if available (1.5+)
1523if ( $.ajaxPrefilter ) {
1524	$.ajaxPrefilter( function( settings, _, xhr ) {
1525		var port = settings.port;
1526		if ( settings.mode === "abort" ) {
1527			if ( pendingRequests[ port ] ) {
1528				pendingRequests[ port ].abort();
1529			}
1530			pendingRequests[ port ] = xhr;
1531		}
1532	} );
1533} else {
1534
1535	// Proxy ajax
1536	ajax = $.ajax;
1537	$.ajax = function( settings ) {
1538		var mode = ( "mode" in settings ? settings : $.ajaxSettings ).mode,
1539			port = ( "port" in settings ? settings : $.ajaxSettings ).port;
1540		if ( mode === "abort" ) {
1541			if ( pendingRequests[ port ] ) {
1542				pendingRequests[ port ].abort();
1543			}
1544			pendingRequests[ port ] = ajax.apply( this, arguments );
1545			return pendingRequests[ port ];
1546		}
1547		return ajax.apply( this, arguments );
1548	};
1549}
1550
1551
1552}));

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.