20 validate:
function( options ) {
24 options && options.debug && window.console && console.warn(
"nothing selected, can't validate, returning nothing" );
29 var validator = $.data(
this[0],
'validator');
34 validator =
new $.validator( options,
this[0] );
35 $.data(
this[0],
'validator', validator);
37 if ( validator.settings.onsubmit ) {
40 this.find(
"input, button").filter(
".cancel").click(
function() {
41 validator.cancelSubmit =
true;
45 if (validator.settings.submitHandler) {
46 this.find(
"input, button").filter(
":submit").click(
function() {
47 validator.submitButton =
this;
52 this.submit(
function( event ) {
53 if ( validator.settings.debug ) {
55 event.preventDefault();
59 if ( validator.settings.submitHandler ) {
60 if (validator.submitButton) {
62 var hidden = $(
"<input type='hidden'/>").attr(
"name", validator.submitButton.name).val(validator.submitButton.value).appendTo(validator.currentForm);
64 validator.settings.submitHandler.call( validator, validator.currentForm );
65 if (validator.submitButton) {
75 if ( validator.cancelSubmit ) {
76 validator.cancelSubmit =
false;
79 if ( validator.form() ) {
80 if ( validator.pendingRequest ) {
81 validator.formSubmitted =
true;
86 validator.focusInvalid();
96 if ( $(
this[0]).is(
'form')) {
97 return this.validate().form();
100 var validator = $(
this[0].form).validate();
101 this.each(
function() {
102 valid &= validator.element(
this);
108 removeAttrs:
function(attributes) {
111 $.each(attributes.split(/\
s/),
function(index, value) {
112 result[value] = $element.attr(value);
113 $element.removeAttr(value);
118 rules:
function(command, argument) {
119 var element =
this[0];
122 var settings = $.data(element.form,
'validator').settings;
123 var staticRules = settings.rules;
124 var existingRules = $.validator.staticRules(element);
127 $.extend(existingRules, $.validator.normalizeRule(argument));
128 staticRules[element.name] = existingRules;
129 if (argument.messages) {
130 settings.messages[element.name] = $.extend( settings.messages[element.name], argument.messages );
135 delete staticRules[element.name];
136 return existingRules;
139 $.each(argument.split(/\
s/),
function(index, method) {
140 filtered[method] = existingRules[method];
141 delete existingRules[method];
147 var data = $.validator.normalizeRules(
150 $.validator.metadataRules(element),
151 $.validator.classRules(element),
152 $.validator.attributeRules(element),
153 $.validator.staticRules(element)
158 var
param = data.required;
159 delete data.required;
160 data = $.extend({required: param}, data);
168 $.extend($.expr[
":"], {
170 blank:
function(a) {
return !$.trim(
"" + a.value);},
172 filled:
function(a) {
return !!$.trim(
"" + a.value);},
174 unchecked:
function(a) {
return !a.checked;}
178 $.validator =
function( options, form ) {
179 this.settings = $.extend(
true, {}, $.validator.defaults, options );
180 this.currentForm = form;
184 $.validator.format =
function(source, params) {
185 if ( arguments.length == 1 ) {
187 var args = $.makeArray(arguments);
188 args.unshift(source);
189 return $.validator.format.apply(
this, args );
192 if ( arguments.length > 2 && params.constructor != Array ) {
193 params = $.makeArray(arguments).slice(1);
195 if ( params.constructor != Array ) {
198 $.each(params,
function(i, n) {
199 source = source.replace(
new RegExp(
"\\{" + i +
"\\}",
"g"), n);
204 $.extend($.validator, {
212 errorElement:
"label",
214 errorContainer: $( [] ),
215 errorLabelContainer: $( [] ),
219 onfocusin:
function(element) {
220 this.lastActive = element;
223 if ( this.settings.focusCleanup && !
this.blockFocusCleanup ) {
224 this.settings.unhighlight && this.settings.unhighlight.call(
this, element, this.settings.errorClass,
this.settings.validClass );
225 this.errorsFor(element).hide();
228 onfocusout:
function(element) {
229 if ( !this.checkable(element) && (element.name in this.submitted || !this.optional(element)) ) {
230 this.element(element);
233 onkeyup:
function(element) {
234 if ( element.name in
this.submitted || element ==
this.lastElement ) {
235 this.element(element);
238 onclick:
function(element) {
240 if ( element.name in
this.submitted ) {
241 this.element(element);
244 else if (element.parentNode.name in
this.submitted) {
245 this.element(element.parentNode);
248 highlight:
function( element, errorClass, validClass ) {
249 $(element).addClass(errorClass).removeClass(validClass);
251 unhighlight:
function( element, errorClass, validClass ) {
252 $(element).removeClass(errorClass).addClass(validClass);
257 setDefaults:
function(settings) {
258 $.extend( $.validator.defaults, settings );
262 required:
"This field is required.",
263 remote:
"Please fix this field.",
264 email:
"Please enter a valid email address.",
265 url:
"Please enter a valid URL.",
266 date:
"Please enter a valid date.",
267 dateISO:
"Please enter a valid date (ISO).",
268 number:
"Please enter a valid number.",
269 digits:
"Please enter only digits.",
270 creditcard:
"Please enter a valid credit card number.",
271 equalTo:
"Please enter the same value again.",
272 accept:
"Please enter a value with a valid extension.",
273 maxlength: $.validator.format(
"Please enter no more than {0} characters."),
274 minlength: $.validator.format(
"Please enter at least {0} characters."),
275 rangelength: $.validator.format(
"Please enter a value between {0} and {1} characters long."),
276 range: $.validator.format(
"Please enter a value between {0} and {1}."),
277 max: $.validator.format(
"Please enter a value less than or equal to {0}."),
278 min: $.validator.format(
"Please enter a value greater than or equal to {0}.")
281 autoCreateRanges:
false,
286 this.labelContainer = $(this.settings.errorLabelContainer);
287 this.errorContext = this.labelContainer.length && this.labelContainer || $(this.currentForm);
288 this.containers = $(this.settings.errorContainer).add( this.settings.errorLabelContainer );
290 this.valueCache = {};
291 this.pendingRequest = 0;
296 var groups = (this.groups = {});
297 $.each(this.settings.groups,
function(key, value) {
298 $.each(value.split(/\s/), function(index, name) {
302 var rules = this.settings.rules;
303 $.each(rules,
function(key, value) {
304 rules[key] = $.validator.normalizeRule(value);
307 function delegate(event) {
308 var validator = $.data(
this[0].form,
"validator"),
309 eventType =
"on" +
event.type.replace(/^validate/,
"");
310 validator.settings[eventType] && validator.settings[eventType].call(validator,
this[0] );
313 .validateDelegate(
":text, :password, :file, select, textarea",
"focusin focusout keyup", delegate)
314 .validateDelegate(
":radio, :checkbox, select, option",
"click", delegate);
316 if (this.settings.invalidHandler) {
317 $(this.currentForm).bind(
"invalid-form.validate", this.settings.invalidHandler);
324 $.extend(this.submitted, this.errorMap);
325 this.invalid = $.extend({}, this.errorMap);
327 $(this.currentForm).triggerHandler(
"invalid-form", [
this]);
333 checkForm:
function() {
335 for ( var i = 0, elements = (this.currentElements = this.elements()); elements[i]; i++ ) {
336 this.check( elements[i] );
342 element:
function( element ) {
343 element = this.clean( element );
344 this.lastElement = element;
345 this.prepareElement( element );
346 this.currentElements = $(element);
347 var result = this.check( element );
349 delete this.invalid[element.name];
351 this.invalid[element.name] =
true;
353 if ( !this.numberOfInvalids() ) {
355 this.toHide = this.toHide.add( this.containers );
362 showErrors:
function(errors) {
365 $.extend( this.errorMap, errors );
367 for ( var name in errors ) {
368 this.errorList.push({
369 message: errors[name],
370 element: this.findByName(name)[0]
374 this.successList = $.grep( this.successList,
function(element) {
375 return !(element.name in errors);
378 this.settings.showErrors
379 ? this.settings.showErrors.call(
this, this.errorMap, this.errorList )
380 : this.defaultShowErrors();
384 resetForm:
function() {
385 if ( $.fn.resetForm ) {
386 $( this.currentForm ).resetForm();
391 this.elements().removeClass( this.settings.errorClass );
394 numberOfInvalids:
function() {
395 return this.objectLength(this.invalid);
398 objectLength:
function( obj ) {
400 for ( var i in obj ) {
406 hideErrors:
function() {
407 this.addWrapper( this.toHide ).hide();
411 return this.size() == 0;
415 return this.errorList.length;
418 focusInvalid:
function() {
419 if( this.settings.focusInvalid ) {
421 $(this.findLastActive() || this.errorList.length && this.errorList[0].element || [])
432 findLastActive:
function() {
433 var lastActive = this.lastActive;
434 return lastActive && $.grep(this.errorList,
function(n) {
435 return n.element.name == lastActive.name;
436 }).length == 1 && lastActive;
439 elements:
function() {
440 var validator =
this,
445 return $([]).add(this.currentForm.elements)
447 .not(
":submit, :reset, :image, [disabled]")
448 .not( this.settings.ignore )
450 !this.name && validator.settings.debug && window.console && console.error(
"%o has no name assigned",
this);
453 if ( this.name in rulesCache || !validator.objectLength($(
this).rules()) ) {
457 rulesCache[this.name] =
true;
462 clean:
function( selector ) {
463 return $( selector )[0];
467 return $( this.settings.errorElement +
"." + this.settings.errorClass, this.errorContext );
471 this.successList = [];
476 this.currentElements = $([]);
479 prepareForm:
function() {
481 this.toHide = this.errors().add( this.containers );
484 prepareElement:
function( element ) {
486 this.toHide = this.errorsFor(element);
489 check:
function( element ) {
490 element = this.clean( element );
493 if (this.checkable(element)) {
494 element = this.findByName( element.name )[0];
497 var rules = $(element).rules();
498 var dependencyMismatch =
false;
499 for( method in rules ) {
500 var rule = { method: method, parameters: rules[method] };
502 var result = $.validator.methods[method].call(
this, element.value.replace(/\r/g,
""), element, rule.parameters );
506 if ( result ==
"dependency-mismatch" ) {
507 dependencyMismatch =
true;
510 dependencyMismatch =
false;
512 if ( result ==
"pending" ) {
513 this.toHide = this.toHide.not( this.errorsFor(element) );
518 this.formatAndAdd( element, rule );
522 this.settings.debug && window.console && console.log(
"exception occured when checking element " + element.id
523 +
", check the '" + rule.method +
"' method", e);
527 if (dependencyMismatch) {
530 if ( this.objectLength(rules) ) {
531 this.successList.push(element);
538 customMetaMessage:
function(element, method) {
543 var meta = this.settings.meta
544 ? $(element).metadata()[this.settings.meta]
545 : $(element).metadata();
547 return meta && meta.messages && meta.messages[method];
551 customMessage:
function( name, method ) {
552 var m = this.settings.messages[name];
553 return m && (m.constructor == String
559 findDefined:
function() {
560 for(var i = 0; i < arguments.length; i++) {
561 if (arguments[i] !== undefined) {
568 defaultMessage:
function( element, method) {
569 return this.findDefined(
570 this.customMessage( element.name, method ),
571 this.customMetaMessage( element, method ),
573 !this.settings.ignoreTitle && element.title || undefined,
574 $.validator.messages[method],
575 "<strong>Warning: No message defined for " + element.name +
"</strong>" 579 formatAndAdd:
function( element, rule ) {
580 var message = this.defaultMessage( element, rule.method ),
581 theregex = /\$?\{(\d+)\}/g;
582 if ( typeof message ==
"function" ) {
583 message = message.call(
this, rule.parameters, element);
584 }
else if (theregex.test(message)) {
585 message = jQuery.format(message.replace(theregex,
'{$1}'), rule.parameters);
587 this.errorList.push({
592 this.errorMap[element.name] = message;
593 this.submitted[element.name] = message;
596 addWrapper:
function(toToggle) {
597 if ( this.settings.wrapper ) {
598 toToggle = toToggle.add( toToggle.parent(
this.settings.wrapper ) );
603 defaultShowErrors:
function() {
604 for ( var i = 0; this.errorList[i]; i++ ) {
605 var error = this.errorList[i];
606 this.settings.highlight && this.settings.highlight.call(
this, error.element,
this.settings.errorClass,
this.settings.validClass );
607 this.showLabel( error.element, error.message );
609 if( this.errorList.length ) {
610 this.toShow = this.toShow.add( this.containers );
612 if (this.settings.success) {
613 for ( var i = 0; this.successList[i]; i++ ) {
614 this.showLabel( this.successList[i] );
617 if (this.settings.unhighlight) {
618 for ( var i = 0, elements = this.validElements(); elements[i]; i++ ) {
619 this.settings.unhighlight.call(
this, elements[i], this.settings.errorClass,
this.settings.validClass );
622 this.toHide = this.toHide.not( this.toShow );
624 this.addWrapper( this.toShow ).show();
627 validElements:
function() {
628 return this.currentElements.not(this.invalidElements());
631 invalidElements:
function() {
632 return $(this.errorList).map(
function() {
637 showLabel:
function(element, message) {
638 var label = this.errorsFor( element );
639 if ( label.length ) {
641 label.removeClass().addClass( this.settings.errorClass );
644 label.attr(
"generated") && label.html(message);
647 label = $(
"<" + this.settings.errorElement +
"/>")
648 .attr({
"for": this.idOrName(element), generated:
true})
649 .addClass(this.settings.errorClass)
650 .html(message ||
"");
651 if ( this.settings.wrapper ) {
654 label = label.hide().show().wrap(
"<" + this.settings.wrapper +
"/>").parent();
656 if ( !this.labelContainer.append(label).length ) {
657 this.settings.errorPlacement
658 ? this.settings.errorPlacement(label, $(element) )
659 : label.insertAfter(element);
662 if ( !message && this.settings.success ) {
664 typeof this.settings.success ==
"string" 665 ? label.addClass( this.settings.success )
666 : this.settings.success( label );
668 this.toShow = this.toShow.add(label);
671 errorsFor:
function(element) {
672 var name = this.idOrName(element);
673 return this.errors().filter(
function() {
674 return $(
this).attr(
'for') == name;
678 idOrName:
function(element) {
679 return this.groups[element.name] || (this.checkable(element) ? element.name : element.id || element.name);
682 checkable:
function( element ) {
683 return /radio|checkbox/i.test(element.type);
686 findByName:
function( name ) {
688 var form = this.currentForm;
689 return $(document.getElementsByName(name)).map(
function(index, element) {
690 return element.form == form && element.name == name && element || null;
694 getLength:
function(value, element) {
695 switch( element.nodeName.toLowerCase() ) {
697 return $(
"option:selected", element).length;
699 if( this.checkable( element) ) {
700 return this.findByName(element.name).filter(
':checked').length;
706 depend:
function(
param, element) {
707 return this.dependTypes[typeof
param]
708 ? this.dependTypes[typeof
param](
param, element)
713 "boolean":
function(
param, element) {
716 "string":
function(
param, element) {
717 return !!$(
param, element.form).length;
719 "function":
function(
param, element) {
720 return param(element);
724 optional:
function(element) {
725 return !$.validator.methods.required.call(
this, $.
trim(element.value), element) &&
"dependency-mismatch";
728 startRequest:
function(element) {
729 if (!this.pending[element.name]) {
730 this.pendingRequest++;
731 this.pending[element.name] =
true;
735 stopRequest:
function(element,
valid) {
736 this.pendingRequest--;
738 if (this.pendingRequest < 0) {
739 this.pendingRequest = 0;
741 delete this.pending[element.name];
742 if ( valid && this.pendingRequest == 0 && this.formSubmitted && this.form() ) {
743 $(this.currentForm).submit();
744 this.formSubmitted =
false;
745 }
else if (!valid && this.pendingRequest == 0 && this.formSubmitted) {
746 $(this.currentForm).triggerHandler(
"invalid-form", [
this]);
747 this.formSubmitted =
false;
751 previousValue:
function(element) {
752 return $.data(element,
"previousValue") || $.data(element,
"previousValue", {
755 message: this.defaultMessage( element,
"remote" )
762 required: {required:
true},
763 email: {email:
true},
766 dateISO: {dateISO:
true},
767 dateDE: {dateDE:
true},
768 number: {number:
true},
769 numberDE: {numberDE:
true},
770 digits: {digits:
true},
771 creditcard: {creditcard:
true}
774 addClassRules:
function(className, rules) {
775 className.constructor == String ?
776 this.classRuleSettings[className] = rules :
777 $.extend(this.classRuleSettings, className);
780 classRules:
function(element) {
782 var classes = $(element).attr(
'class');
783 classes && $.each(classes.split(
' '),
function() {
784 if (
this in $.validator.classRuleSettings) {
785 $.extend(rules, $.validator.classRuleSettings[
this]);
791 attributeRules:
function(element) {
793 var $element = $(element);
795 for (method in $.validator.methods) {
796 var value = $element.attr(method);
798 rules[method] = value;
803 if (rules.maxlength && /-1|2147483647|524288/.test(rules.maxlength)) {
804 delete rules.maxlength;
810 metadataRules:
function(element) {
811 if (!$.metadata)
return {};
813 var meta = $.data(element.form,
'validator').settings.meta;
815 $(element).metadata()[meta] :
816 $(element).metadata();
819 staticRules:
function(element) {
821 var validator = $.data(element.form,
'validator');
822 if (validator.settings.rules) {
823 rules = $.validator.normalizeRule(validator.settings.rules[element.name]) || {};
828 normalizeRules:
function(rules, element) {
830 $.each(rules,
function(prop, val) {
836 if (val.param || val.depends) {
838 switch (typeof val.depends) {
840 keepRule = !!$(val.depends, element.form).length;
843 keepRule = val.depends.call(element, element);
847 rules[prop] = val.param !== undefined ? val.param :
true;
855 $.each(rules,
function(rule, parameter) {
856 rules[rule] = $.isFunction(parameter) ? parameter(element) : parameter;
860 $.each([
'minlength',
'maxlength',
'min',
'max'],
function() {
862 rules[
this] = Number(rules[
this]);
865 $.each([
'rangelength',
'range'],
function() {
867 rules[
this] = [Number(rules[
this][0]), Number(rules[
this][1])];
871 if ($.validator.autoCreateRanges) {
873 if (rules.min && rules.max) {
874 rules.range = [rules.min, rules.max];
878 if (rules.minlength && rules.maxlength) {
879 rules.rangelength = [rules.minlength, rules.maxlength];
880 delete rules.minlength;
881 delete rules.maxlength;
886 if (rules.messages) {
887 delete rules.messages;
894 normalizeRule:
function(data) {
895 if( typeof data ==
"string" ) {
896 var transformed = {};
897 $.each(data.split(/\
s/),
function() {
898 transformed[
this] =
true;
906 addMethod:
function(name, method, message) {
907 $.validator.methods[name] = method;
908 $.validator.messages[name] = message != undefined ? message : $.validator.messages[name];
909 if (method.length < 3) {
910 $.validator.addClassRules(name, $.validator.normalizeRule(name));
917 required:
function(value, element,
param) {
919 if ( !this.depend(
param, element) ) {
920 return "dependency-mismatch";
922 switch( element.nodeName.toLowerCase() ) {
925 var val = $(element).val();
926 return val && val.length > 0;
928 if ( this.checkable(element) ) {
929 return this.getLength(value, element) > 0;
932 return $.trim(value).length > 0;
937 remote:
function(value, element,
param) {
938 if ( this.optional(element) ) {
939 return "dependency-mismatch";
942 var previous = this.previousValue(element);
943 if (!this.settings.messages[element.name] ) {
944 this.settings.messages[element.name] = {};
946 previous.originalMessage = this.settings.messages[element.name].remote;
947 this.settings.messages[element.name].remote = previous.message;
949 param = typeof
param ==
"string" && {url:param} || param;
951 if ( previous.old !== value ) {
952 previous.old = value;
953 var validator =
this;
954 this.startRequest(element);
956 data[element.name] = value;
957 $.ajax($.extend(
true, {
960 port:
"validate" + element.name,
964 validator.settings.messages[element.name].remote = previous.originalMessage;
967 var submitted = validator.formSubmitted;
968 validator.prepareElement(element);
969 validator.formSubmitted = submitted;
970 validator.successList.push(element);
971 validator.showErrors();
974 var message = (previous.message =
response || validator.defaultMessage( element,
"remote" ));
975 errors[element.name] = $.isFunction(message) ? message(value) : message;
976 validator.showErrors(errors);
978 previous.valid =
valid;
979 validator.stopRequest(element, valid);
983 }
else if( this.pending[element.name] ) {
986 return previous.valid;
990 minlength:
function(value, element, param) {
991 return this.optional(element) || this.getLength($.
trim(value), element) >= param;
995 maxlength:
function(value, element, param) {
996 return this.optional(element) || this.getLength($.
trim(value), element) <= param;
1000 rangelength:
function(value, element, param) {
1001 var length = this.getLength($.
trim(value), element);
1002 return this.optional(element) || ( length >= param[0] && length <= param[1] );
1006 min:
function( value, element, param ) {
1007 return this.optional(element) || value >= param;
1011 max:
function( value, element, param ) {
1012 return this.optional(element) || value <= param;
1016 range:
function( value, element, param ) {
1017 return this.optional(element) || ( value >= param[0] && value <= param[1] );
1021 email:
function(value, element) {
1023 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);
1027 url:
function(value, element) {
1029 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); 1032 // http://docs.jquery.com/Plugins/Validation/Methods/date 1033 date: function(value, element) { 1034 return this.optional(element) || !/Invalid|NaN/.test(new Date(value)); 1037 // http://docs.jquery.com/Plugins/Validation/Methods/dateISO 1038 dateISO: function(value, element) { 1039 return this.optional(element) || /^\d{4}[\/-]\d{1,2}[\/-]\d{1,2}$/.test(value); 1042 // http://docs.jquery.com/Plugins/Validation/Methods/number 1043 number: function(value, element) { 1044 return this.optional(element) || /^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d+)?$/.test(value); 1047 // http://docs.jquery.com/Plugins/Validation/Methods/digits 1048 digits: function(value, element) { 1049 return this.optional(element) || /^\d+$/.test(value); 1052 // http://docs.jquery.com/Plugins/Validation/Methods/creditcard 1053 // based on http://en.wikipedia.org/wiki/Luhn 1054 creditcard: function(value, element) { 1055 if ( this.optional(element) ) { 1056 return "dependency-mismatch"; 1058 // accept only digits and dashes 1059 if (/[^0-9-]+/.test(value)) { 1066 value = value.replace(/\D/g, ""); 1068 for (var n = value.length - 1; n >= 0; n--) { 1069 var cDigit = value.charAt(n); 1070 var nDigit = parseInt(cDigit, 10); 1072 if ((nDigit *= 2) > 9) { 1080 return (nCheck % 10) == 0; 1083 // http://docs.jquery.com/Plugins/Validation/Methods/accept 1084 accept: function(value, element, param) { 1085 param = typeof param == "string" ? param.replace(/,/g, '|
') : "png|jpe?g|gif"; 1086 return this.optional(element) || value.match(new RegExp(".(" + param + ")$", "i")); 1089 // http://docs.jquery.com/Plugins/Validation/Methods/equalTo 1090 equalTo: function(value, element, param) { 1091 // bind to the blur event of the target in order to revalidate whenever the target field is updated 1092 // TODO find a way to bind the event just once, avoiding the unbind-rebind overhead 1093 var target = $(param).unbind(".validate-equalTo").bind("blur.validate-equalTo", function() { 1096 return value == target.val(); 1103 // deprecated, use $.validator.format instead 1104 $.format = $.validator.format; 1109 // usage: $.ajax({ mode: "abort"[, port: "uniqueport"]}); 1110 // if mode:"abort" is used, the previous request on that port (port can be undefined) is aborted via XMLHttpRequest.abort() 1113 var pendingRequests = {}; 1114 $.ajax = function(settings) { 1115 // create settings for compatibility with ajaxSetup 1116 settings = $.extend(settings, $.extend({}, $.ajaxSettings, settings)); 1117 var port = settings.port; 1118 if (settings.mode == "abort") { 1119 if ( pendingRequests[port] ) { 1120 pendingRequests[port].abort(); 1122 return (pendingRequests[port] = ajax.apply(this, arguments)); 1124 return ajax.apply(this, arguments); 1128 // provides cross-browser focusin and focusout events 1129 // IE has native support, in other browsers, use event caputuring (neither bubbles) 1131 // provides delegate(type: String, delegate: Selector, handler: Callback) plugin for easier event delegation 1132 // handler is only called when $(event.target).is(delegate), in the scope of the jquery-object for event.target 1134 // only implement if not provided by jQuery core (since 1.4) 1135 // TODO verify if jQuery 1.4's implementation is compatible with older jQuery special-event APIs
1136 if (!jQuery.event.special.focusin && !jQuery.event.special.focusout && document.addEventListener) {
1140 },
function( original, fix ){
1141 $.event.special[fix] = {
1143 this.addEventListener( original, handler,
true );
1145 teardown:
function() {
1146 this.removeEventListener( original, handler,
true );
1148 handler:
function(e) {
1149 arguments[0] = $.event.fix(e);
1150 arguments[0].type = fix;
1151 return $.event.handle.apply(
this, arguments);
1154 function handler(e) {
1157 return $.event.handle.call(
this, e);
1162 validateDelegate:
function(delegate, type, handler) {
1163 return this.bind(type,
function(event) {
1164 var target = $(
event.target);
1165 if (target.is(delegate)) {
1166 return handler.apply(target, arguments);
int s
The socket that the CLI will use to communicate.
int valid
If the information stored in buffer is valid.
FUNCTION int min(int user_perm, int permExternal)
Get the minimum permission level required.
if(!preg_match("/\s$projectGroup\s/", $groups)&&(posix_getgid()!=$gInfo['gid']))
get monk license list of one specified uploadtree_id
FUNCTION int max(int permGroup, int permPublic)
Get the maximum group privilege.
int response
Is a response expected from the scheduler.
char * trim(char *ptext)
Trimming whitespace.