PageSourceSearch

http://bayalagbuteegch.mn/js/jquery.validate.js

js bayalagbuteegch.mn collected 2026-10-04 13:28:52 UTC 38,952 bytes, 1,232 lines download raw bytes

1/*!
2 * jQuery Validation Plugin 1.11.1
3 *
4 * http://bassistance.de/jquery-plugins/jquery-plugin-validation/
5 * http://docs.jquery.com/Plugins/Validation
6 *
7 * Copyright 2013 Jörn Zaefferer
8 * Released under the MIT license:
9 *   http://www.opensource.org/licenses/mit-license.php
10 */
11
12
13(function($) {
14
15$.extend($.fn, {
16	// http://docs.jquery.com/Plugins/Validation/validate
17	validate: function( options ) {
18
19		// if nothing is selected, return nothing; can't chain anyway
20		if ( !this.length ) {
21			if ( options && options.debug && window.console ) {
22				console.warn( "Nothing selected, can't validate, returning nothing." );
23			}
24			return;
25		}
26
27		// check if a validator for this form was already created
28		var validator = $.data( this[0], "validator" );
29		if ( validator ) {
30			return validator;
31		}
32
33		// Add novalidate tag if HTML5.
34		this.attr( "novalidate", "novalidate" );
35
36		validator = new $.validator( options, this[0] );
37		$.data( this[0], "validator", validator );
38
39		if ( validator.settings.onsubmit ) {
40
41			this.validateDelegate( ":submit", "click", function( event ) {
42				if ( validator.settings.submitHandler ) {
43					validator.submitButton = event.target;
44				}
45				// allow suppressing validation by adding a cancel class to the submit button
46				if ( $(event.target).hasClass("cancel") ) {
47					validator.cancelSubmit = true;
48				}
49
50				// allow suppressing validation by adding the html5 formnovalidate attribute to the submit button
51				if ( $(event.target).attr("formnovalidate") !== undefined ) {
52					validator.cancelSubmit = true;
53				}
54			});
55
56			// validate the form on submit
57			this.submit( function( event ) {
58				if ( validator.settings.debug ) {
59					// prevent form submit to be able to see console output
60					event.preventDefault();
61				}
62				function handle() {
63					var hidden;
64					if ( validator.settings.submitHandler ) {
65						if ( validator.submitButton ) {
66							// insert a hidden input as a replacement for the missing submit button
67							hidden = $("<input type='hidden'/>").attr("name", validator.submitButton.name).val( $(validator.submitButton).val() ).appendTo(validator.currentForm);
68						}
69						validator.settings.submitHandler.call( validator, validator.currentForm, event );
70						if ( validator.submitButton ) {
71							// and clean up afterwards; thanks to no-block-scope, hidden can be referenced
72							hidden.remove();
73						}
74						return false;
75					}
76					return true;
77				}
78
79				// prevent submit for invalid forms or custom submit handlers
80				if ( validator.cancelSubmit ) {
81					validator.cancelSubmit = false;
82					return handle();
83				}
84				if ( validator.form() ) {
85					if ( validator.pendingRequest ) {
86						validator.formSubmitted = true;
87						return false;
88					}
89					return handle();
90				} else {
91					validator.focusInvalid();
92					return false;
93				}
94			});
95		}
96
97		return validator;
98	},
99	// http://docs.jquery.com/Plugins/Validation/valid
100	valid: function() {
101		if ( $(this[0]).is("form")) {
102			return this.validate().form();
103		} else {
104			var valid = true;
105			var validator = $(this[0].form).validate();
106			this.each(function() {
107				valid = valid && validator.element(this);
108			});
109			return valid;
110		}
111	},
112	// attributes: space seperated list of attributes to retrieve and remove
113	removeAttrs: function( attributes ) {
114		var result = {},
115			$element = this;
116		$.each(attributes.split(/\s/), function( index, value ) {
117			result[value] = $element.attr(value);
118			$element.removeAttr(value);
119		});
120		return result;
121	},
122	// http://docs.jquery.com/Plugins/Validation/rules
123	rules: function( command, argument ) {
124		var element = this[0];
125
126		if ( command ) {
127			var settings = $.data(element.form, "validator").settings;
128			var staticRules = settings.rules;
129			var existingRules = $.validator.staticRules(element);
130			switch(command) {
131			case "add":
132				$.extend(existingRules, $.validator.normalizeRule(argument));
133				// remove messages from rules, but allow them to be set separetely
134				delete existingRules.messages;
135				staticRules[element.name] = existingRules;
136				if ( argument.messages ) {
137					settings.messages[element.name] = $.extend( settings.messages[element.name], argument.messages );
138				}
139				break;
140			case "remove":
141				if ( !argument ) {
142					delete staticRules[element.name];
143					return existingRules;
144				}
145				var filtered = {};
146				$.each(argument.split(/\s/), function( index, method ) {
147					filtered[method] = existingRules[method];
148					delete existingRules[method];
149				});
150				return filtered;
151			}
152		}
153
154		var data = $.validator.normalizeRules(
155		$.extend(
156			{},
157			$.validator.classRules(element),
158			$.validator.attributeRules(element),
159			$.validator.dataRules(element),
160			$.validator.staticRules(element)
161		), element);
162
163		// make sure required is at front
164		if ( data.required ) {
165			var param = data.required;
166			delete data.required;
167			data = $.extend({required: param}, data);
168		}
169
170		return data;
171	}
172});
173
174// Custom selectors
175$.extend($.expr[":"], {
176	// http://docs.jquery.com/Plugins/Validation/blank
177	blank: function( a ) { return !$.trim("" + $(a).val()); },
178	// http://docs.jquery.com/Plugins/Validation/filled
179	filled: function( a ) { return !!$.trim("" + $(a).val()); },
180	// http://docs.jquery.com/Plugins/Validation/unchecked
181	unchecked: function( a ) { return !$(a).prop("checked"); }
182});
183
184// constructor for validator
185$.validator = function( options, form ) {
186	this.settings = $.extend( true, {}, $.validator.defaults, options );
187	this.currentForm = form;
188	this.init();
189};
190
191$.validator.format = function( source, params ) {
192	if ( arguments.length === 1 ) {
193		return function() {
194			var args = $.makeArray(arguments);
195			args.unshift(source);
196			return $.validator.format.apply( this, args );
197		};
198	}
199	if ( arguments.length > 2 && params.constructor !== Array  ) {
200		params = $.makeArray(arguments).slice(1);
201	}
202	if ( params.constructor !== Array ) {
203		params = [ params ];
204	}
205	$.each(params, function( i, n ) {
206		source = source.replace( new RegExp("\\{" + i + "\\}", "g"), function() {
207			return n;
208		});
209	});
210	return source;
211};
212
213$.extend($.validator, {
214
215	defaults: {
216		messages: {},
217		groups: {},
218		rules: {},
219		errorClass: "error",
220		validClass: "valid",
221		errorElement: "label",
222		focusInvalid: true,
223		errorContainer: $([]),
224		errorLabelContainer: $([]),
225		onsubmit: true,
226		ignore: ":hidden",
227		ignoreTitle: false,
228		onfocusin: function( element, event ) {
229			this.lastActive = element;
230
231			// hide error label and remove error class on focus if enabled
232			if ( this.settings.focusCleanup && !this.blockFocusCleanup ) {
233				if ( this.settings.unhighlight ) {
234					this.settings.unhighlight.call( this, element, this.settings.errorClass, this.settings.validClass );
235				}
236				this.addWrapper(this.errorsFor(element)).hide();
237			}
238		},
239		onfocusout: function( element, event ) {
240			if ( !this.checkable(element) && (element.name in this.submitted || !this.optional(element)) ) {
241				this.element(element);
242			}
243		},
244		onkeyup: function( element, event ) {
245			if ( event.which === 9 && this.elementValue(element) === "" ) {
246				return;
247			} else if ( element.name in this.submitted || element === this.lastElement ) {
248				this.element(element);
249			}
250		},
251		onclick: function( element, event ) {
252			// click on selects, radiobuttons and checkboxes
253			if ( element.name in this.submitted ) {
254				this.element(element);
255			}
256			// or option elements, check parent select in that case
257			else if ( element.parentNode.name in this.submitted ) {
258				this.element(element.parentNode);
259			}
260		},
261		highlight: function( element, errorClass, validClass ) {
262			if ( element.type === "radio" ) {
263				this.findByName(element.name).addClass(errorClass).removeClass(validClass);
264			} else {
265				$(element).addClass(errorClass).removeClass(validClass);
266			}
267		},
268		unhighlight: function( element, errorClass, validClass ) {
269			if ( element.type === "radio" ) {
270				this.findByName(element.name).removeClass(errorClass).addClass(validClass);
271			} else {
272				$(element).removeClass(errorClass).addClass(validClass);
273			}
274		}
275	},
276
277	// http://docs.jquery.com/Plugins/Validation/Validator/setDefaults
278	setDefaults: function( settings ) {
279		$.extend( $.validator.defaults, settings );
280	},
281
282	messages: {
283		required: "This field is required.",
284		remote: "Please fix this field.",
285		email: "Please enter a valid email address.",
286		url: "Please enter a valid URL.",
287		date: "Please enter a valid date.",
288		dateISO: "Please enter a valid date (ISO).",
289		number: "Please enter a valid number.",
290		digits: "Please enter only digits.",
291		creditcard: "Please enter a valid credit card number.",
292		equalTo: "Please enter the same value again.",
293		maxlength: $.validator.format("Please enter no more than {0} characters."),
294		minlength: $.validator.format("Please enter at least {0} characters."),
295		rangelength: $.validator.format("Please enter a value between {0} and {1} characters long."),
296		range: $.validator.format("Please enter a value between {0} and {1}."),
297		max: $.validator.format("Please enter a value less than or equal to {0}."),
298		min: $.validator.format("Please enter a value greater than or equal to {0}.")
299	},
300
301	autoCreateRanges: false,
302
303	prototype: {
304
305		init: function() {
306			this.labelContainer = $(this.settings.errorLabelContainer);
307			this.errorContext = this.labelContainer.length && this.labelContainer || $(this.currentForm);
308			this.containers = $(this.settings.errorContainer).add( this.settings.errorLabelContainer );
309			this.submitted = {};
310			this.valueCache = {};
311			this.pendingRequest = 0;
312			this.pending = {};
313			this.invalid = {};
314			this.reset();
315
316			var groups = (this.groups = {});
317			$.each(this.settings.groups, function( key, value ) {
318				if ( typeof value === "string" ) {
319					value = value.split(/\s/);
320				}
321				$.each(value, function( index, name ) {
322					groups[name] = key;
323				});
324			});
325			var rules = this.settings.rules;
326			$.each(rules, function( key, value ) {
327				rules[key] = $.validator.normalizeRule(value);
328			});
329
330			function delegate(event) {
331				var validator = $.data(this[0].form, "validator"),
332					eventType = "on" + event.type.replace(/^validate/, "");
333				if ( validator.settings[eventType] ) {
334					validator.settings[eventType].call(validator, this[0], event);
335				}
336			}
337			$(this.currentForm)
338				.validateDelegate(":text, [type='password'], [type='file'], select, textarea, " +
339					"[type='number'], [type='search'] ,[type='tel'], [type='url'], " +
340					"[type='email'], [type='datetime'], [type='date'], [type='month'], " +
341					"[type='week'], [type='time'], [type='datetime-local'], " +
342					"[type='range'], [type='color'] ",
343					"focusin focusout keyup", delegate)
344				.validateDelegate("[type='radio'], [type='checkbox'], select, option", "click", delegate);
345
346			if ( this.settings.invalidHandler ) {
347				$(this.currentForm).bind("invalid-form.validate", this.settings.invalidHandler);
348			}
349		},
350
351		// http://docs.jquery.com/Plugins/Validation/Validator/form
352		form: function() {
353			this.checkForm();
354			$.extend(this.submitted, this.errorMap);
355			this.invalid = $.extend({}, this.errorMap);
356			if ( !this.valid() ) {
357				$(this.currentForm).triggerHandler("invalid-form", [this]);
358			}
359			this.showErrors();
360			return this.valid();
361		},
362
363		checkForm: function() {
364			this.prepareForm();
365			for ( var i = 0, elements = (this.currentElements = this.elements()); elements[i]; i++ ) {
366				this.check( elements[i] );
367			}
368			return this.valid();
369		},
370
371		// http://docs.jquery.com/Plugins/Validation/Validator/element
372		element: function( element ) {
373			element = this.validationTargetFor( this.clean( element ) );
374			this.lastElement = element;
375			this.prepareElement( element );
376			this.currentElements = $(element);
377			var result = this.check( element ) !== false;
378			if ( result ) {
379				delete this.invalid[element.name];
380			} else {
381				this.invalid[element.name] = true;
382			}
383			if ( !this.numberOfInvalids() ) {
384				// Hide error containers on last error
385				this.toHide = this.toHide.add( this.containers );
386			}
387			this.showErrors();
388			return result;
389		},
390
391		// http://docs.jquery.com/Plugins/Validation/Validator/showErrors
392		showErrors: function( errors ) {
393			if ( errors ) {
394				// add items to error list and map
395				$.extend( this.errorMap, errors );
396				this.errorList = [];
397				for ( var name in errors ) {
398					this.errorList.push({
399						message: errors[name],
400						element: this.findByName(name)[0]
401					});
402				}
403				// remove items from success list
404				this.successList = $.grep( this.successList, function( element ) {
405					return !(element.name in errors);
406				});
407			}
408			if ( this.settings.showErrors ) {
409				this.settings.showErrors.call( this, this.errorMap, this.errorList );
410			} else {
411				this.defaultShowErrors();
412			}
413		},
414
415		// http://docs.jquery.com/Plugins/Validation/Validator/resetForm
416		resetForm: function() {
417			if ( $.fn.resetForm ) {
418				$(this.currentForm).resetForm();
419			}
420			this.submitted = {};
421			this.lastElement = null;
422			this.prepareForm();
423			this.hideErrors();
424			this.elements().removeClass( this.settings.errorClass ).removeData( "previousValue" );
425		},
426
427		numberOfInvalids: function() {
428			return this.objectLength(this.invalid);
429		},
430
431		objectLength: function( obj ) {
432			var count = 0;
433			for ( var i in obj ) {
434				count++;
435			}
436			return count;
437		},
438
439		hideErrors: function() {
440			this.addWrapper( this.toHide ).hide();
441		},
442
443		valid: function() {
444			return this.size() === 0;
445		},
446
447		size: function() {
448			return this.errorList.length;
449		},
450
451		focusInvalid: function() {
452			if ( this.settings.focusInvalid ) {
453				try {
454					$(this.findLastActive() || this.errorList.length && this.errorList[0].element || [])
455					.filter(":visible")
456					.focus()
457					// manually trigger focusin event; without it, focusin handler isn't called, findLastActive won't have anything to find
458					.trigger("focusin");
459				} catch(e) {
460					// ignore IE throwing errors when focusing hidden elements
461				}
462			}
463		},
464
465		findLastActive: function() {
466			var lastActive = this.lastActive;
467			return lastActive && $.grep(this.errorList, function( n ) {
468				return n.element.name === lastActive.name;
469			}).length === 1 && lastActive;
470		},
471
472		elements: function() {
473			var validator = this,
474				rulesCache = {};
475
476			// select all valid inputs inside the form (no submit or reset buttons)
477			return $(this.currentForm)
478			.find("input, select, textarea")
479			.not(":submit, :reset, :image, [disabled]")
480			.not( this.settings.ignore )
481			.filter(function() {
482				if ( !this.name && validator.settings.debug && window.console ) {
483					console.error( "%o has no name assigned", this);
484				}
485
486				// select only the first element for each name, and only those with rules specified
487				if ( this.name in rulesCache || !validator.objectLength($(this).rules()) ) {
488					return false;
489				}
490
491				rulesCache[this.name] = true;
492				return true;
493			});
494		},
495
496		clean: function( selector ) {
497			return $(selector)[0];
498		},
499
500		errors: function() {
501			var errorClass = this.settings.errorClass.replace(" ", ".");
502			return $(this.settings.errorElement + "." + errorClass, this.errorContext);
503		},
504
505		reset: function() {
506			this.successList = [];
507			this.errorList = [];
508			this.errorMap = {};
509			this.toShow = $([]);
510			this.toHide = $([]);
511			this.currentElements = $([]);
512		},
513
514		prepareForm: function() {
515			this.reset();
516			this.toHide = this.errors().add( this.containers );
517		},
518
519		prepareElement: function( element ) {
520			this.reset();
521			this.toHide = this.errorsFor(element);
522		},
523
524		elementValue: function( element ) {
525			var type = $(element).attr("type"),
526				val = $(element).val();
527
528			if ( type === "radio" || type === "checkbox" ) {
529				return $("input[name='" + $(element).attr("name") + "']:checked").val();
530			}
531
532			if ( typeof val === "string" ) {
533				return val.replace(/\r/g, "");
534			}
535			return val;
536		},
537
538		check: function( element ) {
539			element = this.validationTargetFor( this.clean( element ) );
540
541			var rules = $(element).rules();
542			var dependencyMismatch = false;
543			var val = this.elementValue(element);
544			var result;
545
546			for (var method in rules ) {
547				var rule = { method: method, parameters: rules[method] };
548				try {
549
550					result = $.validator.methods[method].call( this, val, element, rule.parameters );
551
552					// if a method indicates that the field is optional and therefore valid,
553					// don't mark it as valid when there are no other rules
554					if ( result === "dependency-mismatch" ) {
555						dependencyMismatch = true;
556						continue;
557					}
558					dependencyMismatch = false;
559
560					if ( result === "pending" ) {
561						this.toHide = this.toHide.not( this.errorsFor(element) );
562						return;
563					}
564
565					if ( !result ) {
566						this.formatAndAdd( element, rule );
567						return false;
568					}
569				} catch(e) {
570					if ( this.settings.debug && window.console ) {
571						console.log( "Exception occurred when checking element " + element.id + ", check the '" + rule.method + "' method.", e );
572					}
573					throw e;
574				}
575			}
576			if ( dependencyMismatch ) {
577				return;
578			}
579			if ( this.objectLength(rules) ) {
580				this.successList.push(element);
581			}
582			return true;
583		},
584
585		// return the custom message for the given element and validation method
586		// specified in the element's HTML5 data attribute
587		customDataMessage: function( element, method ) {
588			return $(element).data("msg-" + method.toLowerCase()) || (element.attributes && $(element).attr("data-msg-" + method.toLowerCase()));
589		},
590
591		// return the custom message for the given element name and validation method
592		customMessage: function( name, method ) {
593			var m = this.settings.messages[name];
594			return m && (m.constructor === String ? m : m[method]);
595		},
596
597		// return the first defined argument, allowing empty strings
598		findDefined: function() {
599			for(var i = 0; i < arguments.length; i++) {
600				if ( arguments[i] !== undefined ) {
601					return arguments[i];
602				}
603			}
604			return undefined;
605		},
606
607		defaultMessage: function( element, method ) {
608			return this.findDefined(
609				this.customMessage( element.name, method ),
610				this.customDataMessage( element, method ),
611				// title is never undefined, so handle empty string as undefined
612				!this.settings.ignoreTitle && element.title || undefined,
613				$.validator.messages[method],
614				"<strong>Warning: No message defined for " + element.name + "</strong>"
615			);
616		},
617
618		formatAndAdd: function( element, rule ) {
619			var message = this.defaultMessage( element, rule.method ),
620				theregex = /\$?\{(\d+)\}/g;
621			if ( typeof message === "function" ) {
622				message = message.call(this, rule.parameters, element);
623			} else if (theregex.test(message)) {
624				message = $.validator.format(message.replace(theregex, "{$1}"), rule.parameters);
625			}
626			this.errorList.push({
627				message: message,
628				element: element
629			});
630
631			this.errorMap[element.name] = message;
632			this.submitted[element.name] = message;
633		},
634
635		addWrapper: function( toToggle ) {
636			if ( this.settings.wrapper ) {
637				toToggle = toToggle.add( toToggle.parent( this.settings.wrapper ) );
638			}
639			return toToggle;
640		},
641
642		defaultShowErrors: function() {
643			var i, elements;
644			for ( i = 0; this.errorList[i]; i++ ) {
645				var error = this.errorList[i];
646				if ( this.settings.highlight ) {
647					this.settings.highlight.call( this, error.element, this.settings.errorClass, this.settings.val
647idClass );
648				}
649				this.showLabel( error.element, error.message );
650			}
651			if ( this.errorList.length ) {
652				this.toShow = this.toShow.add( this.containers );
653			}
654			if ( this.settings.success ) {
655				for ( i = 0; this.successList[i]; i++ ) {
656					this.showLabel( this.successList[i] );
657				}
658			}
659			if ( this.settings.unhighlight ) {
660				for ( i = 0, elements = this.validElements(); elements[i]; i++ ) {
661					this.settings.unhighlight.call( this, elements[i], this.settings.errorClass, this.settings.validClass );
662				}
663			}
664			this.toHide = this.toHide.not( this.toShow );
665			this.hideErrors();
666			this.addWrapper( this.toShow ).show();
667		},
668
669		validElements: function() {
670			return this.currentElements.not(this.invalidElements());
671		},
672
673		invalidElements: function() {
674			return $(this.errorList).map(function() {
675				return this.element;
676			});
677		},
678
679		showLabel: function( element, message ) {
680			var label = this.errorsFor( element );
681			if ( label.length ) {
682				// refresh error/success class
683				label.removeClass( this.settings.validClass ).addClass( this.settings.errorClass );
684				// replace message on existing label
685				label.html(message);
686			} else {
687				// create label
688				label = $("<" + this.settings.errorElement + ">")
689					.attr("for", this.idOrName(element))
690					.addClass(this.settings.errorClass)
691					.html(message || "");
692				if ( this.settings.wrapper ) {
693					// make sure the element is visible, even in IE
694					// actually showing the wrapped element is handled elsewhere
695					label = label.hide().show().wrap("<" + this.settings.wrapper + "/>").parent();
696				}
697				if ( !this.labelContainer.append(label).length ) {
698					if ( this.settings.errorPlacement ) {
699						this.settings.errorPlacement(label, $(element) );
700					} else {
701						label.insertAfter(element);
702					}
703				}
704			}
705			if ( !message && this.settings.success ) {
706				label.text("");
707				if ( typeof this.settings.success === "string" ) {
708					label.addClass( this.settings.success );
709				} else {
710					this.settings.success( label, element );
711				}
712			}
713			this.toShow = this.toShow.add(label);
714		},
715
716		errorsFor: function( element ) {
717			var name = this.idOrName(element);
718			return this.errors().filter(function() {
719				return $(this).attr("for") === name;
720			});
721		},
722
723		idOrName: function( element ) {
724			return this.groups[element.name] || (this.checkable(element) ? element.name : element.id || element.name);
725		},
726
727		validationTargetFor: function( element ) {
728			// if radio/checkbox, validate first element in group instead
729			if ( this.checkable(element) ) {
730				element = this.findByName( element.name ).not(this.settings.ignore)[0];
731			}
732			return element;
733		},
734
735		checkable: function( element ) {
736			return (/radio|checkbox/i).test(element.type);
737		},
738
739		findByName: function( name ) {
740			return $(this.currentForm).find("[name='" + name + "']");
741		},
742
743		getLength: function( value, element ) {
744			switch( element.nodeName.toLowerCase() ) {
745			case "select":
746				return $("option:selected", element).length;
747			case "input":
748				if ( this.checkable( element) ) {
749					return this.findByName(element.name).filter(":checked").length;
750				}
751			}
752			return value.length;
753		},
754
755		depend: function( param, element ) {
756			return this.dependTypes[typeof param] ? this.dependTypes[typeof param](param, element) : true;
757		},
758
759		dependTypes: {
760			"boolean": function( param, element ) {
761				return param;
762			},
763			"string": function( param, element ) {
764				return !!$(param, element.form).length;
765			},
766			"function": function( param, element ) {
767				return param(element);
768			}
769		},
770
771		optional: function( element ) {
772			var val = this.elementValue(element);
773			return !$.validator.methods.required.call(this, val, element) && "dependency-mismatch";
774		},
775
776		startRequest: function( element ) {
777			if ( !this.pending[element.name] ) {
778				this.pendingRequest++;
779				this.pending[element.name] = true;
780			}
781		},
782
783		stopRequest: function( element, valid ) {
784			this.pendingRequest--;
785			// sometimes synchronization fails, make sure pendingRequest is never < 0
786			if ( this.pendingRequest < 0 ) {
787				this.pendingRequest = 0;
788			}
789			delete this.pending[element.name];
790			if ( valid && this.pendingRequest === 0 && this.formSubmitted && this.form() ) {
791				$(this.currentForm).submit();
792				this.formSubmitted = false;
793			} else if (!valid && this.pendingRequest === 0 && this.formSubmitted) {
794				$(this.currentForm).triggerHandler("invalid-form", [this]);
795				this.formSubmitted = false;
796			}
797		},
798
799		previousValue: function( element ) {
800			return $.data(element, "previousValue") || $.data(element, "previousValue", {
801				old: null,
802				valid: true,
803				message: this.defaultMessage( element, "remote" )
804			});
805		}
806
807	},
808
809	classRuleSettings: {
810		required: {required: true},
811		email: {email: true},
812		url: {url: true},
813		date: {date: true},
814		dateISO: {dateISO: true},
815		number: {number: true},
816		digits: {digits: true},
817		creditcard: {creditcard: true}
818	},
819
820	addClassRules: function( className, rules ) {
821		if ( className.constructor === String ) {
822			this.classRuleSettings[className] = rules;
823		} else {
824			$.extend(this.classRuleSettings, className);
825		}
826	},
827
828	classRules: function( element ) {
829		var rules = {};
830		var classes = $(element).attr("class");
831		if ( classes ) {
832			$.each(classes.split(" "), function() {
833				if ( this in $.validator.classRuleSettings ) {
834					$.extend(rules, $.validator.classRuleSettings[this]);
835				}
836			});
837		}
838		return rules;
839	},
840
841	attributeRules: function( element ) {
842		var rules = {};
843		var $element = $(element);
844		var type = $element[0].getAttribute("type");
845
846		for (var method in $.validator.methods) {
847			var value;
848
849			// support for <input required> in both html5 and older browsers
850			if ( method === "required" ) {
851				value = $element.get(0).getAttribute(method);
852				// Some browsers return an empty string for the required attribute
853				// and non-HTML5 browsers might have required="" markup
854				if ( value === "" ) {
855					value = true;
856				}
857				// force non-HTML5 browsers to return bool
858				value = !!value;
859			} else {
860				value = $element.attr(method);
861			}
862
863			// convert the value to a number for number inputs, and for text for backwards compability
864			// allows type="date" and others to be compared as strings
865			if ( /min|max/.test( method ) && ( type === null || /number|range|text/.test( type ) ) ) {
866				value = Number(value);
867			}
868
869			if ( value ) {
870				rules[method] = value;
871			} else if ( type === method && type !== 'range' ) {
872				// exception: the jquery validate 'range' method
873				// does not test for the html5 'range' type
874				rules[method] = true;
875			}
876		}
877
878		// maxlength may be returned as -1, 2147483647 (IE) and 524288 (safari) for text inputs
879		if ( rules.maxlength && /-1|2147483647|524288/.test(rules.maxlength) ) {
880			delete rules.maxlength;
881		}
882
883		return rules;
884	},
885
886	dataRules: function( element ) {
887		var method, value,
888			rules = {}, $element = $(element);
889		for (method in $.validator.methods) {
890			value = $element.data("rule-" + method.toLowerCase());
891			if ( value !== undefined ) {
892				rules[method] = value;
893			}
894		}
895		return rules;
896	},
897
898	staticRules: function( element ) {
899		var rules = {};
900		var validator = $.data(element.form, "validator");
901		if ( validator.settings.rules ) {
902			rules = $.validator.normalizeRule(validator.settings.rules[element.name]) || {};
903		}
904		return rules;
905	},
906
907	normalizeRules: function( rules, element ) {
908		// handle dependency check
909		$.each(rules, function( prop, val ) {
910			// ignore rule when param is explicitly false, eg. required:false
911			if ( val === false ) {
912				delete rules[prop];
913				return;
914			}
915			if ( val.param || val.depends ) {
916				var keepRule = true;
917				switch (typeof val.depends) {
918				case "string":
919					keepRule = !!$(val.depends, element.form).length;
920					break;
921				case "function":
922					keepRule = val.depends.call(element, element);
923					break;
924				}
925				if ( keepRule ) {
926					rules[prop] = val.param !== undefined ? val.param : true;
927				} else {
928					delete rules[prop];
929				}
930			}
931		});
932
933		// evaluate parameters
934		$.each(rules, function( rule, parameter ) {
935			rules[rule] = $.isFunction(parameter) ? parameter(element) : parameter;
936		});
937
938		// clean number parameters
939		$.each(['minlength', 'maxlength'], function() {
940			if ( rules[this] ) {
941				rules[this] = Number(rules[this]);
942			}
943		});
944		$.each(['rangelength', 'range'], function() {
945			var parts;
946			if ( rules[this] ) {
947				if ( $.isArray(rules[this]) ) {
948					rules[this] = [Number(rules[this][0]), Number(rules[this][1])];
949				} else if ( typeof rules[this] === "string" ) {
950					parts = rules[this].split(/[\s,]+/);
951					rules[this] = [Number(parts[0]), Number(parts[1])];
952				}
953			}
954		});
955
956		if ( $.validator.autoCreateRanges ) {
957			// auto-create ranges
958			if ( rules.min && rules.max ) {
959				rules.range = [rules.min, rules.max];
960				delete rules.min;
961				delete rules.max;
962			}
963			if ( rules.minlength && rules.maxlength ) {
964				rules.rangelength = [rules.minlength, rules.maxlength];
965				delete rules.minlength;
966				delete rules.maxlength;
967			}
968		}
969
970		return rules;
971	},
972
vendor: 4,896 bytes, lines 973-1053
973	// Converts a simple string to a {string: true} rule, e.g., "required" to {required:true}
974	normalizeRule: function( data ) {
975		if ( typeof data === "string" ) {
976			var transformed = {};
977			$.each(data.split(/\s/), function() {
978				transformed[this] = true;
979			});
980			data = transformed;
981		}
982		return data;
983	},
984
985	// http://docs.jquery.com/Plugins/Validation/Validator/addMethod
986	addMethod: function( name, method, message ) {
987		$.validator.methods[name] = method;
988		$.validator.messages[name] = message !== undefined ? message : $.validator.messages[name];
989		if ( method.length < 3 ) {
990			$.validator.addClassRules(name, $.validator.normalizeRule(name));
991		}
992	},
993
994	methods: {
995
996		// http://docs.jquery.com/Plugins/Validation/Methods/required
997		required: function( value, element, param ) {
998			// check if dependency is met
999			if ( !this.depend(param, element) ) {
1000				return "dependency-mismatch";
1001			}
1002			if ( element.nodeName.toLowerCase() === "select" ) {
1003				// could be an array for select-multiple or a string, both are fine this way
1004				var val = $(element).val();
1005				return val && val.length > 0;
1006			}
1007			if ( this.checkable(element) ) {
1008				return this.getLength(value, element) > 0;
1009			}
1010			return $.trim(value).length > 0;
1011		},
1012
1013		// http://docs.jquery.com/Plugins/Validation/Methods/email
1014		email: function( value, element ) {
1015			// contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/
1016			return this.optional(element) || /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i.test(value);
1017		},
1018
1019		// http://docs.jquery.com/Plugins/Validation/Methods/url
1020		url: function( value, element ) {
1021			// contributed by Scott Gonzalez: http://projects.scottsplayground.com/iri/
1022			return this.optional(element) || /^(https?|s?ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(value);
1023		},
1024
1025		// http://docs.jquery.com/Plugins/Validation/Methods/date
1026		date: function( value, element ) {
1027			return this.optional(element) || !/Invalid|NaN/.test(new Date(value).toString());
1028		},
1029
1030		// http://docs.jquery.com/Plugins/Validation/Methods/dateISO
1031		dateISO: function( value, element ) {
1032			return this.optional(element) || /^\d{4}[\/\-]\d{1,2}[\/\-]\d{1,2}$/.test(value);
1033		},
1034
1035		// http://docs.jquery.com/Plugins/Validation/Methods/number
1036		number: function( value, element ) {
1037			return this.optional(element) || /^-?(?:\d+|\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/.test(value);
1038		},
1039
1040		// http://docs.jquery.com/Plugins/Validation/Methods/digits
1041		digits: function( value, element ) {
1042			return this.optional(element) || /^\d+$/.test(value);
1043		},
1044
1045		// http://docs.jquery.com/Plugins/Validation/Methods/creditcard
1046		// based on http://en.wikipedia.org/wiki/Luhn
1047		creditcard: function( value, element ) {
1048			if ( this.optional(element) ) {
1049				return "dependency-mismatch";
1050			}
1051			// accept only spaces, digits and dashes
1052			if ( /[^0-9 \-]+/.test(value) ) {
1053				return false;
1054			}
1055			var nCheck = 0,
1056				nDigit = 0,
1057				bEven = false;
1058
1059			value = value.replace(/\D/g, "");
1060
1061			for (var n = value.length - 1; n >= 0; n--) {
1062				var cDigit = value.charAt(n);
1063				nDigit = parseInt(cDigit, 10);
1064				if ( bEven ) {
1065					if ( (nDigit *= 2) > 9 ) {
1066						nDigit -= 9;
1067					}
1068				}
1069				nCheck += nDigit;
1070				bEven = !bEven;
1071			}
1072
1073			return (nCheck % 10) === 0;
1074		},
1075
1076		// http://docs.jquery.com/Plugins/Validation/Methods/minlength
1077		minlength: function( value, element, param ) {
1078			var length = $.isArray( value ) ? value.length : this.getLength($.trim(value), element);
1079			return this.optional(element) || length >= param;
1080		},
1081
1082		// http://docs.jquery.com/Plugins/Validation/Methods/maxlength
1083		maxlength: function( value, element, param ) {
1084			var length = $.isArray( value ) ? value.length : this.getLength($.trim(value), element);
1085			return this.optional(element) || length <= param;
1086		},
1087
1088		// http://docs.jquery.com/Plugins/Validation/Methods/rangelength
1089		rangelength: function( value, element, param ) {
1090			var length = $.isArray( value ) ? value.length : this.getLength($.trim(value), element);
1091			return this.optional(element) || ( length >= param[0] && length <= param[1] );
1092		},
1093
1094		// http://docs.jquery.com/Plugins/Validation/Methods/min
1095		min: function( value, element, param ) {
1096			return this.optional(element) || value >= param;
1097		},
1098
1099		// http://docs.jquery.com/Plugins/Validation/Methods/max
1100		max: function( value, element, param ) {
1101			return this.optional(element) || value <= param;
1102		},
1103
1104		// http://docs.jquery.com/Plugins/Validation/Methods/range
1105		range: function( value, element, param ) {
1106			return this.optional(element) || ( value >= param[0] && value <= param[1] );
1107		},
1108
1109		// http://docs.jquery.com/Plugins/Validation/Methods/equalTo
1110		equalTo: function( value, element, param ) {
1111			// bind to the blur event of the target in order to revalidate whenever the target field is updated
1112			// TODO find a way to bind the event just once, avoiding the unbind-rebind overhead
1113			var target = $(param);
1114			if ( this.settings.onfocusout ) {
1115				target.unbind(".validate-equalTo").bind("blur.validate-equalTo", function() {
1116					$(element).valid();
1117				});
1118			}
1119			return value === target.val();
1120		},
1121
1122		// http://docs.jquery.com/Plugins/Validation/Methods/remote
1123		remote: function( value, element, param ) {
1124			if ( this.optional(element) ) {
1125				return "dependency-mismatch";
1126			}
1127
1128			var previous = this.previousValue(element);
1129			if (!this.settings.messages[element.name] ) {
1130				this.settings.messages[element.name] = {};
1131			}
1132			previous.originalMessage = this.settings.messages[element.name].remote;
1133			this.settings.messages[element.name].remote = previous.message;
1134
1135			param = typeof param === "string" && {url:param} || param;
1136
1137			if ( previous.old === value ) {
1138				return previous.valid;
1139			}
1140
1141			previous.old = value;
1142			var validator = this;
1143			this.startRequest(element);
1144			var data = {};
1145			data[element.name] = value;
1146			$.ajax($.extend(true, {
1147				url: param,
1148				mode: "abort",
1149				port: "validate" + element.name,
1150				dataType: "json",
1151				data: data,
1152				success: function( response ) {
1153					validator.settings.messages[element.name].remote = previous.originalMessage;
1154					var valid = response === true || response === "true";
1155					if ( valid ) {
1156						var submitted = validator.formSubmitted;
1157						validator.prepareElement(element);
1158						validator.formSubmitted = submitted;
1159						validator.successList.push(element);
1160						delete validator.invalid[element.name];
1161						validator.showErrors();
1162					} else {
1163						var errors = {};
1164						var message = response || validator.defaultMessage( element, "remote" );
1165						errors[element.name] = previous.message = $.isFunction(message) ? message(value) : message;
1166						validator.invalid[element.name] = true;
1167						validator.showErrors(errors);
1168					}
1169					previous.valid = valid;
1170					validator.stopRequest(element, valid);
1171				}
1172			}, param));
1173			return "pending";
1174		}
1175
1176	}
1177
1178});
1179
1180// deprecated, use $.validator.format instead
1181$.format = $.validator.format;
1182
1183}(jQuery));
1184
1185// ajax mode: abort
1186// usage: $.ajax({ mode: "abort"[, port: "uniqueport"]});
1187// if mode:"abort" is used, the previous request on that port (port can be undefined) is aborted via XMLHttpRequest.abort()
1188(function($) {
1189	var pendingRequests = {};
1190	// Use a prefilter if available (1.5+)
1191	if ( $.ajaxPrefilter ) {
1192		$.ajaxPrefilter(function( settings, _, xhr ) {
1193			var port = settings.port;
1194			if ( settings.mode === "abort" ) {
1195				if ( pendingRequests[port] ) {
1196					pendingRequests[port].abort();
1197				}
1198				pendingRequests[port] = xhr;
1199			}
1200		});
1201	} else {
1202		// Proxy ajax
1203		var ajax = $.ajax;
1204		$.ajax = function( settings ) {
1205			var mode = ( "mode" in settings ? settings : $.ajaxSettings ).mode,
1206				port = ( "port" in settings ? settings : $.ajaxSettings ).port;
1207			if ( mode === "abort" ) {
1208				if ( pendingRequests[port] ) {
1209					pendingRequests[port].abort();
1210				}
1211				pendingRequests[port] = ajax.apply(this, arguments);
1212				return pendingRequests[port];
1213			}
1214			return ajax.apply(this, arguments);
1215		};
1216	}
1217}(jQuery));
1218
1219// provides delegate(type: String, delegate: Selector, handler: Callback) plugin for easier event delegation
1220// handler is only called when $(event.target).is(delegate), in the scope of the jquery-object for event.target
1221(function($) {
1222	$.extend($.fn, {
1223		validateDelegate: function( delegate, type, handler ) {
1224			return this.bind(type, function( event ) {
1225				var target = $(event.target);
1226				if ( target.is(delegate) ) {
1227					return handler.apply(target, arguments);
1228				}
1229			});
1230		}
1231	});
1232}(jQuery));

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.