PageSourceSearch

https://biafo.com/js/jquery.validate.js

js biafo.com collected 2026-10-02 19:09:20 UTC 51,107 bytes, 1,660 lines download raw bytes

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

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.