PageSourceSearch

https://www.orisysinfotech.com/js/jquery.validate.min.js

js orisysinfotech.com collected 2026-10-04 17:04:11 UTC 37,580 bytes, 1,173 lines download raw bytes

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