PageSourceSearch

https://vmis.in/js/admin_js/jquery.validate.js

js vmis.in collected 2026-10-02 10:50:04 UTC 40,195 bytes, 1,270 lines download raw bytes

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