jquery.validate.extend.js
32.3 KB
/*! dili 2015-11-04 */
function isIdCardNo(num){num=num.toUpperCase();var intCheckDigit,factorArr=new Array(7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2,1),parityBit=new Array("1","0","X","9","8","7","6","5","4","3","2"),varArray=new Array,lngProduct=0,intStrLen=num.length,idNumber=num;if(15!=intStrLen&&18!=intStrLen)return!1;for(i=0;i<intStrLen;i++){if(varArray[i]=idNumber.charAt(i),(varArray[i]<"0"||varArray[i]>"9")&&17!=i)return!1;i<17&&(varArray[i]=varArray[i]*factorArr[i])}if(18==intStrLen){var date8=idNumber.substring(6,14);if(0==isDate8(date8))return!1;for(i=0;i<17;i++)lngProduct+=varArray[i];if(intCheckDigit=parityBit[lngProduct%11],varArray[17]!=intCheckDigit)return!1}else{var date6=idNumber.substring(6,12);if(0==isDate6(date6))return!1}return!0}function isDate6(sDate){if(!/^[0-9]{6}$/.test(sDate))return!1;var year,month,myDate=new Date,nowyear=myDate.getFullYear();return year=sDate.substring(0,4),month=sDate.substring(4,6),year>nowyear?!1:1700>year||year>2500?!1:1>month||month>12?!1:!0}function isDate8(sDate){if(!/^[0-9]{8}$/.test(sDate))return!1;var year,month,day,myDate=new Date,nowyear=myDate.getFullYear();year=sDate.substring(0,4),month=sDate.substring(4,6),day=sDate.substring(6,8);var iaMonthDays=[31,28,31,30,31,30,31,31,30,31,30,31];return year>nowyear?!1:1700>year||year>2500?!1:((year%4==0&&year%100!=0||year%400==0)&&(iaMonthDays[1]=29),1>month||month>12?!1:1>day||day>iaMonthDays[month-1]?!1:!0)}function reg(value){var len=value.length;switch(len){case 13:return/[0-9a-zA-Z]{13}/.test(value);case 15:return/[0-9a-zA-Z]{15}/.test(value);case 18:return/[0-9a-zA-Z]{18}/.test(value);default:return!1}}!function($){$.extend($.fn,{validate:function(options){if(!this.length)return void(options&&options.debug&&window.console&&console.warn("nothing selected, can't validate, returning nothing"));var validator=$.data(this[0],"validator");return validator?validator:(this.attr("novalidate","novalidate"),validator=new $.validator(options,this[0]),$.data(this[0],"validator",validator),validator.settings.onsubmit&&(this.validateDelegate(":submit","click",function(ev){validator.settings.submitHandler&&(validator.submitButton=ev.target),$(ev.target).hasClass("cancel")&&(validator.cancelSubmit=!0)}),this.submit(function(event){function handle(){var hidden;return validator.settings.submitHandler?(validator.submitButton&&(hidden=$("<input type='hidden'/>").attr("name",validator.submitButton.name).val(validator.submitButton.value).appendTo(validator.currentForm)),validator.settings.submitHandler.call(validator,validator.currentForm,event),validator.submitButton&&hidden.remove(),!1):!0}return validator.settings.debug&&event.preventDefault(),validator.cancelSubmit?(validator.cancelSubmit=!1,handle()):validator.form()?validator.pendingRequest?(validator.formSubmitted=!0,!1):handle():(validator.focusInvalid(),!1)})),validator)},valid:function(){if($(this[0]).is("form"))return this.validate().form();var valid=!0,validator=$(this[0].form).validate();return this.each(function(){valid&=validator.element(this)}),valid},removeAttrs:function(attributes){var result={},$element=this;return $.each(attributes.split(/\s/),function(index,value){result[value]=$element.attr(value),$element.removeAttr(value)}),result},rules:function(command,argument){var element=this[0];if(command){var settings=$.data(element.form,"validator").settings,staticRules=settings.rules,existingRules=$.validator.staticRules(element);switch(command){case"add":$.extend(existingRules,$.validator.normalizeRule(argument)),staticRules[element.name]=existingRules,argument.messages&&(settings.messages[element.name]=$.extend(settings.messages[element.name],argument.messages));break;case"remove":if(!argument)return delete staticRules[element.name],existingRules;var filtered={};return $.each(argument.split(/\s/),function(index,method){filtered[method]=existingRules[method],delete existingRules[method]}),filtered}}var data=$.validator.normalizeRules($.extend({},$.validator.metadataRules(element),$.validator.classRules(element),$.validator.attributeRules(element),$.validator.staticRules(element)),element);if(data.required){var param=data.required;delete data.required,data=$.extend({required:param},data)}return data}}),$.extend($.expr[":"],{blank:function(a){return!$.trim(""+a.value)},filled:function(a){return!!$.trim(""+a.value)},unchecked:function(a){return!a.checked}}),$.validator=function(options,form){this.settings=$.extend(!0,{},$.validator.defaults,options),this.currentForm=form,this.init()},$.validator.format=function(source,params){return 1===arguments.length?function(){var args=$.makeArray(arguments);return args.unshift(source),$.validator.format.apply(this,args)}:(arguments.length>2&¶ms.constructor!==Array&&(params=$.makeArray(arguments).slice(1)),params.constructor!==Array&&(params=[params]),$.each(params,function(i,n){source=source.replace(new RegExp("\\{"+i+"\\}","g"),n)}),source)},$.extend($.validator,{defaults:{messages:{},groups:{},rules:{},errorClass:"error",validClass:"valid",errorElement:"label",focusInvalid:!0,errorContainer:$([]),errorLabelContainer:$([]),onsubmit:!0,ignore:":hidden",ignoreTitle:!1,onfocusin:function(element,event){this.lastActive=element,this.settings.focusCleanup&&!this.blockFocusCleanup&&(this.settings.unhighlight&&this.settings.unhighlight.call(this,element,this.settings.errorClass,this.settings.validClass),this.addWrapper(this.errorsFor(element)).hide())},onfocusout:function(element,event){this.checkable(element)||!(element.name in this.submitted)&&this.optional(element)||this.element(element)},onkeyup:function(element,event){(9!==event.which||""!==this.elementValue(element))&&(element.name in this.submitted||element===this.lastActive)&&this.element(element)},onclick:function(element,event){element.name in this.submitted?this.element(element):element.parentNode.name in this.submitted&&this.element(element.parentNode)},highlight:function(element,errorClass,validClass){"radio"===element.type?this.findByName(element.name).addClass(errorClass).removeClass(validClass):$(element).addClass(errorClass).removeClass(validClass)},unhighlight:function(element,errorClass,validClass){"radio"===element.type?this.findByName(element.name).removeClass(errorClass).addClass(validClass):$(element).removeClass(errorClass).addClass(validClass)}},setDefaults:function(settings){$.extend($.validator.defaults,settings)},messages:{required:"This field is required.",remote:"Please fix this field.",email:"Please enter a valid email address.",url:"Please enter a valid URL.",date:"Please enter a valid date.",dateISO:"Please enter a valid date (ISO).",number:"Please enter a valid number.",digits:"Please enter only digits.",creditcard:"Please enter a valid credit card number.",equalTo:"Please enter the same value again.",maxlength:$.validator.format("Please enter no more than {0} characters."),minlength:$.validator.format("Please enter at least {0} characters."),rangelength:$.validator.format("Please enter a value between {0} and {1} characters long."),range:$.validator.format("Please enter a value between {0} and {1}."),max:$.validator.format("Please enter a value less than or equal to {0}."),min:$.validator.format("Please enter a value greater than or equal to {0}.")},autoCreateRanges:!1,prototype:{init:function(){function delegate(event){var validator=$.data(this[0].form,"validator"),eventType="on"+event.type.replace(/^validate/,"");validator&&validator.settings[eventType]&&validator.settings[eventType].call(validator,this[0],event)}this.labelContainer=$(this.settings.errorLabelContainer),this.errorContext=this.labelContainer.length&&this.labelContainer||$(this.currentForm),this.containers=$(this.settings.errorContainer).add(this.settings.errorLabelContainer),this.submitted={},this.valueCache={},this.pendingRequest=0,this.pending={},this.invalid={},this.reset();var groups=this.groups={};$.each(this.settings.groups,function(key,value){$.each(value.split(/\s/),function(index,name){groups[name]=key})});var rules=this.settings.rules;$.each(rules,function(key,value){rules[key]=$.validator.normalizeRule(value)}),$(this.currentForm).validateDelegate(":text, [type='password'], [type='file'], select, textarea, [type='number'], [type='search'] ,[type='tel'], [type='url'], [type='email'], [type='datetime'], [type='date'], [type='month'], [type='week'], [type='time'], [type='datetime-local'], [type='range'], [type='color'] ","focusin focusout keyup",delegate).validateDelegate("[type='radio'], [type='checkbox'], select, option","click",delegate),this.settings.invalidHandler&&$(this.currentForm).bind("invalid-form.validate",this.settings.invalidHandler)},form:function(){return this.checkForm(),$.extend(this.submitted,this.errorMap),this.invalid=$.extend({},this.errorMap),this.valid()||$(this.currentForm).triggerHandler("invalid-form",[this]),this.showErrors(),this.valid()},checkForm:function(){this.prepareForm();for(var i=0,elements=this.currentElements=this.elements();elements[i];i++)this.check(elements[i]);return this.valid()},element:function(element){element=this.validationTargetFor(this.clean(element)),this.lastElement=element,this.prepareElement(element),this.currentElements=$(element);var result=this.check(element)!==!1;return result?delete this.invalid[element.name]:this.invalid[element.name]=!0,this.numberOfInvalids()||(this.toHide=this.toHide.add(this.containers)),this.showErrors(),result},showErrors:function(errors){if(errors){$.extend(this.errorMap,errors),this.errorList=[];for(var name in errors)this.errorList.push({message:errors[name],element:this.findByName(name)[0]});this.successList=$.grep(this.successList,function(element){return!(element.name in errors)})}this.settings.showErrors?this.settings.showErrors.call(this,this.errorMap,this.errorList):this.defaultShowErrors()},resetForm:function(){$.fn.resetForm&&$(this.currentForm).resetForm(),this.submitted={},this.lastElement=null,this.prepareForm(),this.hideErrors(),this.elements().removeClass(this.settings.errorClass).removeData("previousValue")},numberOfInvalids:function(){return this.objectLength(this.invalid)},objectLength:function(obj){var count=0;for(var i in obj)count++;return count},hideErrors:function(){this.addWrapper(this.toHide).hide()},valid:function(){return 0===this.size()},size:function(){return this.errorList.length},focusInvalid:function(){if(this.settings.focusInvalid)try{$(this.findLastActive()||this.errorList.length&&this.errorList[0].element||[]).filter(":visible").focus().trigger("focusin")}catch(e){}},findLastActive:function(){var lastActive=this.lastActive;return lastActive&&1===$.grep(this.errorList,function(n){return n.element.name===lastActive.name}).length&&lastActive},elements:function(){var validator=this,rulesCache={};return $(this.currentForm).find("input, select, textarea").not(":submit, :reset, :image, [disabled]").not(this.settings.ignore).filter(function(){return!this.name&&validator.settings.debug&&window.console&&console.error("%o has no name assigned",this),this.name in rulesCache||!validator.objectLength($(this).rules())?!1:(rulesCache[this.name]=!0,!0)})},clean:function(selector){return $(selector)[0]},errors:function(){var errorClass=this.settings.errorClass.replace(" ",".");return $(this.settings.errorElement+"."+errorClass,this.errorContext)},reset:function(){this.successList=[],this.errorList=[],this.errorMap={},this.toShow=$([]),this.toHide=$([]),this.currentElements=$([])},prepareForm:function(){this.reset(),this.toHide=this.errors().add(this.containers)},prepareElement:function(element){this.reset(),this.toHide=this.errorsFor(element)},elementValue:function(element){var type=$(element).attr("type"),val=$(element).val();return"radio"===type||"checkbox"===type?$('input[name="'+$(element).attr("name")+'"]:checked').val():"string"==typeof val?val.replace(/\r/g,""):val},check:function(element){element=this.validationTargetFor(this.clean(element));var result,rules=$(element).rules(),dependencyMismatch=!1,val=this.elementValue(element);for(var method in rules){var rule={method:method,parameters:rules[method]};try{if(result=$.validator.methods[method].call(this,val,element,rule.parameters),"dependency-mismatch"===result){dependencyMismatch=!0;continue}if(dependencyMismatch=!1,"pending"===result)return void(this.toHide=this.toHide.not(this.errorsFor(element)));if(!result)return this.formatAndAdd(element,rule),!1}catch(e){throw this.settings.debug&&window.console&&console.log("exception occured when checking element "+element.id+", check the '"+rule.method+"' method",e),e}}return dependencyMismatch?void 0:(this.objectLength(rules)&&this.successList.push(element),!0)},customMetaMessage:function(element,method){if($.metadata){var meta=this.settings.meta?$(element).metadata()[this.settings.meta]:$(element).metadata();return meta&&meta.messages&&meta.messages[method]}},customDataMessage:function(element,method){return $(element).data("msg-"+method.toLowerCase())||element.attributes&&$(element).attr("data-msg-"+method.toLowerCase())},customMessage:function(name,method){var m=this.settings.messages[name];return m&&(m.constructor===String?m:m[method])},findDefined:function(){for(var i=0;i<arguments.length;i++)if(void 0!==arguments[i])return arguments[i];return void 0},defaultMessage:function(element,method){return this.findDefined(this.customMessage(element.name,method),this.customDataMessage(element,method),this.customMetaMessage(element,method),!this.settings.ignoreTitle&&element.title||void 0,$.validator.messages[method],"<strong>Warning: No message defined for "+element.name+"</strong>")},formatAndAdd:function(element,rule){var message=this.defaultMessage(element,rule.method),theregex=/\$?\{(\d+)\}/g;"function"==typeof message?message=message.call(this,rule.parameters,element):theregex.test(message)&&(message=$.validator.format(message.replace(theregex,"{$1}"),rule.parameters)),this.errorList.push({message:message,element:element}),this.errorMap[element.name]=message,this.submitted[element.name]=message},addWrapper:function(toToggle){return this.settings.wrapper&&(toToggle=toToggle.add(toToggle.parent(this.settings.wrapper))),toToggle},defaultShowErrors:function(){var i,elements;for(i=0;this.errorList[i];i++){var error=this.errorList[i];this.settings.highlight&&this.settings.highlight.call(this,error.element,this.settings.errorClass,this.settings.validClass),this.showLabel(error.element,error.message)}if(this.errorList.length&&(this.toShow=this.toShow.add(this.containers)),this.settings.success)for(i=0;this.successList[i];i++)this.showLabel(this.successList[i]);if(this.settings.unhighlight)for(i=0,elements=this.validElements();elements[i];i++)this.settings.unhighlight.call(this,elements[i],this.settings.errorClass,this.settings.validClass);this.toHide=this.toHide.not(this.toShow),this.hideErrors(),this.addWrapper(this.toShow).show()},validElements:function(){return this.currentElements.not(this.invalidElements())},invalidElements:function(){return $(this.errorList).map(function(){return this.element})},showLabel:function(element,message){var label=this.errorsFor(element);label.length?(label.removeClass(this.settings.validClass).addClass(this.settings.errorClass),label.attr("generated")&&label.html(message)):(label=$("<"+this.settings.errorElement+"/>").attr({"for":this.idOrName(element),generated:!0}).addClass(this.settings.errorClass).html(message||""),this.settings.wrapper&&(label=label.hide().show().wrap("<"+this.settings.wrapper+"/>").parent()),this.labelContainer.append(label).length||(this.settings.errorPlacement?this.settings.errorPlacement(label,$(element)):label.insertAfter(element))),!message&&this.settings.success&&(label.text(""),"string"==typeof this.settings.success?label.addClass(this.settings.success):this.settings.success(label,element)),this.toShow=this.toShow.add(label)},errorsFor:function(element){var name=this.idOrName(element);return this.errors().filter(function(){return $(this).attr("for")===name})},idOrName:function(element){return this.groups[element.name]||(this.checkable(element)?element.name:element.id||element.name)},validationTargetFor:function(element){return this.checkable(element)&&(element=this.findByName(element.name).not(this.settings.ignore)[0]),element},checkable:function(element){return/radio|checkbox/i.test(element.type)},findByName:function(name){return $(this.currentForm).find('[name="'+name+'"]')},getLength:function(value,element){switch(element.nodeName.toLowerCase()){case"select":return $("option:selected",element).length;case"input":if(this.checkable(element))return this.findByName(element.name).filter(":checked").length}return value.length},depend:function(param,element){return this.dependTypes[typeof param]?this.dependTypes[typeof param](param,element):!0},dependTypes:{"boolean":function(param,element){return param},string:function(param,element){return!!$(param,element.form).length},"function":function(param,element){return param(element)}},optional:function(element){var val=this.elementValue(element);return!$.validator.methods.required.call(this,val,element)&&"dependency-mismatch"},startRequest:function(element){this.pending[element.name]||(this.pendingRequest++,this.pending[element.name]=!0)},stopRequest:function(element,valid){this.pendingRequest--,this.pendingRequest<0&&(this.pendingRequest=0),delete this.pending[element.name],valid&&0===this.pendingRequest&&this.formSubmitted&&this.form()?($(this.currentForm).submit(),this.formSubmitted=!1):!valid&&0===this.pendingRequest&&this.formSubmitted&&($(this.currentForm).triggerHandler("invalid-form",[this]),this.formSubmitted=!1)},previousValue:function(element){return $.data(element,"previousValue")||$.data(element,"previousValue",{old:null,valid:!0,message:this.defaultMessage(element,"remote")})}},classRuleSettings:{required:{required:!0},email:{email:!0},url:{url:!0},date:{date:!0},dateISO:{dateISO:!0},number:{number:!0},digits:{digits:!0},creditcard:{creditcard:!0}},addClassRules:function(className,rules){className.constructor===String?this.classRuleSettings[className]=rules:$.extend(this.classRuleSettings,className)},classRules:function(element){var rules={},classes=$(element).attr("class");return classes&&$.each(classes.split(" "),function(){this in $.validator.classRuleSettings&&$.extend(rules,$.validator.classRuleSettings[this])}),rules},attributeRules:function(element){var rules={},$element=$(element);for(var method in $.validator.methods){var value;"required"===method?(value=$element.get(0).getAttribute(method),""===value&&(value=!0),value=!!value):value=$element.attr(method),value?rules[method]=value:$element[0].getAttribute("type")===method&&(rules[method]=!0)}return rules.maxlength&&/-1|2147483647|524288/.test(rules.maxlength)&&delete rules.maxlength,rules},metadataRules:function(element){if(!$.metadata)return{};var meta=$.data(element.form,"validator").settings.meta;return meta?$(element).metadata()[meta]:$(element).metadata()},staticRules:function(element){var rules={},validator=$.data(element.form,"validator");return validator.settings.rules&&(rules=$.validator.normalizeRule(validator.settings.rules[element.name])||{}),rules},normalizeRules:function(rules,element){return $.each(rules,function(prop,val){if(val===!1)return void delete rules[prop];if(val.param||val.depends){var keepRule=!0;switch(typeof val.depends){case"string":keepRule=!!$(val.depends,element.form).length;break;case"function":keepRule=val.depends.call(element,element)}keepRule?rules[prop]=void 0!==val.param?val.param:!0:delete rules[prop]}}),$.each(rules,function(rule,parameter){rules[rule]=$.isFunction(parameter)?parameter(element):parameter}),$.each(["minlength","maxlength","min","max"],function(){rules[this]&&(rules[this]=Number(rules[this]))}),$.each(["rangelength","range"],function(){var parts;rules[this]&&($.isArray(rules[this])?rules[this]=[Number(rules[this][0]),Number(rules[this][1])]:"string"==typeof rules[this]&&(parts=rules[this].replace(/[\[\]]/g,"").split(/[\s,]+/),rules[this]=[Number(parts[0]),Number(parts[1])]))}),$.validator.autoCreateRanges&&(rules.min&&rules.max&&(rules.range=[rules.min,rules.max],delete rules.min,delete rules.max),rules.minlength&&rules.maxlength&&(rules.rangelength=[rules.minlength,rules.maxlength],delete rules.minlength,delete rules.maxlength)),rules.messages&&delete rules.messages,rules},normalizeRule:function(data){if("string"==typeof data){var transformed={};$.each(data.split(/\s/),function(){transformed[this]=!0}),data=transformed}return data},addMethod:function(name,method,message){$.validator.methods[name]=method,$.validator.messages[name]=void 0!==message?message:$.validator.messages[name],method.length<3&&$.validator.addClassRules(name,$.validator.normalizeRule(name))},methods:{required:function(value,element,param){if(!this.depend(param,element))return"dependency-mismatch";if("select"===element.nodeName.toLowerCase()){var val=$(element).val();return val&&val.length>0}return this.checkable(element)?this.getLength(value,element)>0:$.trim(value).length>0},remote:function(value,element,param){if(this.optional(element))return"dependency-mismatch";var previous=this.previousValue(element);if(this.settings.messages[element.name]||(this.settings.messages[element.name]={}),previous.originalMessage=this.settings.messages[element.name].remote,this.settings.messages[element.name].remote=previous.message,param="string"==typeof param&&{url:param}||param,this.pending[element.name])return"pending";if(previous.old===value)return previous.valid;previous.old=value;var validator=this;this.startRequest(element);var data={};return data[element.name]=value,$.ajax($.extend(!0,{url:param,mode:"abort",port:"validate"+element.name,dataType:"json",data:data,success:function(response){validator.settings.messages[element.name].remote=previous.originalMessage;var valid=response===!0||"true"===response;if(valid){var submitted=validator.formSubmitted;validator.prepareElement(element),validator.formSubmitted=submitted,validator.successList.push(element),delete validator.invalid[element.name],validator.showErrors()}else{var errors={},message=response||validator.defaultMessage(element,"remote");errors[element.name]=previous.message=$.isFunction(message)?message(value):message,validator.invalid[element.name]=!0,validator.showErrors(errors)}previous.valid=valid,validator.stopRequest(element,valid)}},param)),"pending"},minlength:function(value,element,param){var length=$.isArray(value)?value.length:this.getLength($.trim(value),element);return this.optional(element)||length>=param},maxlength:function(value,element,param){var length=$.isArray(value)?value.length:this.getLength($.trim(value),element);return this.optional(element)||param>=length},rangelength:function(value,element,param){var length=$.isArray(value)?value.length:this.getLength($.trim(value),element);return this.optional(element)||length>=param[0]&&length<=param[1]},min:function(value,element,param){return this.optional(element)||value>=param},max:function(value,element,param){return this.optional(element)||param>=value},range:function(value,element,param){return this.optional(element)||value>=param[0]&&value<=param[1]},email:function(value,element){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)},url:function(value,element){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)},date:function(value,element){return this.optional(element)||!/Invalid|NaN/.test(new Date(value))},dateISO:function(value,element){return this.optional(element)||/^\d{4}[\/\-]\d{1,2}[\/\-]\d{1,2}$/.test(value)},number:function(value,element){return this.optional(element)||/^-?(?:\d+|\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/.test(value)},digits:function(value,element){return this.optional(element)||/^\d+$/.test(value)},creditcard:function(value,element){if(this.optional(element))return"dependency-mismatch";if(/[^0-9 \-]+/.test(value))return!1;var nCheck=0,nDigit=0,bEven=!1;value=value.replace(/\D/g,"");for(var n=value.length-1;n>=0;n--){var cDigit=value.charAt(n);nDigit=parseInt(cDigit,10),bEven&&(nDigit*=2)>9&&(nDigit-=9),nCheck+=nDigit,bEven=!bEven}return nCheck%10===0},equalTo:function(value,element,param){var target=$(param);return this.settings.onfocusout&&target.unbind(".validate-equalTo").bind("blur.validate-equalTo",function(){$(element).valid()}),value===target.val()}}}),$.format=$.validator.format}(jQuery),function($){var pendingRequests={};if($.ajaxPrefilter)$.ajaxPrefilter(function(settings,_,xhr){var port=settings.port;"abort"===settings.mode&&(pendingRequests[port]&&pendingRequests[port].abort(),pendingRequests[port]=xhr)});else{var ajax=$.ajax;$.ajax=function(settings){var mode=("mode"in settings?settings:$.ajaxSettings).mode,port=("port"in settings?settings:$.ajaxSettings).port;return"abort"===mode?(pendingRequests[port]&&pendingRequests[port].abort(),pendingRequests[port]=ajax.apply(this,arguments)):ajax.apply(this,arguments)}}}(jQuery),function($){jQuery.event.special.focusin||jQuery.event.special.focusout||!document.addEventListener||$.each({focus:"focusin",blur:"focusout"},function(original,fix){function handler(e){return e=$.event.fix(e),e.type=fix,$.event.handle.call(this,e)}$.event.special[fix]={setup:function(){this.addEventListener(original,handler,!0)},teardown:function(){this.removeEventListener(original,handler,!0)},handler:function(e){var args=arguments;return args[0]=$.event.fix(e),args[0].type=fix,$.event.handle.apply(this,args)}}}),$.extend($.fn,{validateDelegate:function(delegate,type,handler){return this.bind(type,function(event){var target=$(event.target);return target.is(delegate)?handler.apply(target,arguments):void 0})}})}(jQuery),jQuery.extend(jQuery.validator.messages,{required:"必填内容",remote:"请勿输入非法字符与非法关键词",email:"请输入正确格式的电子邮件",url:"请输入合法的网址",date:"请输入合法的日期",dateISO:"请输入合法的日期 (ISO).",number:"请输入合法的数字",digits:"只能输入正整数",creditcard:"请输入合法的信用卡号",equalTo:"请再次输入相同的值",accept:"请输入拥有合法后缀名的字符串",money:"请输入正确的金额格式",maxlength:jQuery.validator.format("请输入一个长度最多是 {0} 的字符串"),minlength:jQuery.validator.format("请输入一个长度最少是 {0} 的字符串"),rangelength:jQuery.validator.format("请输入一个长度介于 {0} 和 {1} 之间的字符串"),range:jQuery.validator.format("请输入一个介于 {0} 和 {1} 之间的值"),max:jQuery.validator.format("请输入一个最大为 {0} 的值"),min:jQuery.validator.format("请输入一个最小为 {0} 的值"),notIllegalCharacter:"请输入正确的内容",isPhone:"请输入正确的电话号码",isMultiPhone:"请输入正确的电话号码",isChar:"请填写正确的中文, 字母或者数字"}),$.validator.setDefaults({focusInvalid:!0,focusCleanup:!1}),$.validator.setDefaults({errorPlacement:function(error,element){try{element.parent().is("span")?error.addClass("new-error-placement").appendTo(element.parent().parent()):error.addClass("new-error-placement").appendTo(element.parent("td"))}catch(e){$(element).focus()}}}),jQuery.validator.addMethod("isIdCardNo",function(value,element){return this.optional(element)||isIdCardNo(value)},"请正确输入您的身份证号码"),jQuery.validator.addMethod("isMobile",function(value,element){var length=value.length;return this.optional(element)||11==length&&/^1[3-8]\d{9}$/.test(value)},"请填写正确的手机号码"),jQuery.validator.addMethod("isVerifCode",function(value,element){var length=value.length;return this.optional(element)||6==length&&/^\d{6}$/.test(value)},"请填写正确的验证码"),jQuery.validator.addMethod("isCompany",function(value,element){value.length;return this.optional(element)||/^[\u4E00-\u9FA5]+$/.test(value)},"请填写正确的企业名称"),jQuery.validator.addMethod("isChar",function(value,element){value.length;return this.optional(element)||/^[\u4E00-\u9FA50-9a-zA-Z]+$/.test(value)},"请填写正确的中文, 字母或者数字!"),jQuery.validator.addMethod("isConcat",function(value,element){value.length;return this.optional(element)||/^[\u4E00-\u9FA50-9a-zA-Z\-]+$/.test(value)},"输入中含有非法字符!"),jQuery.validator.addMethod("isRealName",function(value,element){return this.optional(element)||/^[\u4E00-\u9FA5+·]{2,10}$/.test(value)&&!/^[\u4E00-\u9FA5+·]{2,10}[·]$/.test(value)&&!/^[·][\u4E00-\u9FA5+.]{2,10}$/.test(value)},"请填写正确的名字"),jQuery.validator.addMethod("money",function(value,element){var money=/^([1-9][0-9]+|[0-9])(\.\d{1,2})?$/;return this.optional(element)||money.test(value)},"请输入正确的金额"),jQuery.validator.addMethod("isPhone",function(value,element){var phone=/((^\d{11}$)|^((\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1}))$)/;return this.optional(element)||phone.test(value)},"请输入正确的电话号码"),jQuery.validator.addMethod("isMultiPhone",function(value,element){var phone=/^(((\d{11})|((\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})))([;、;,、,]?))+$/;return this.optional(element)||phone.test(value)},"请输入正确的电话号码"),jQuery.validator.addMethod("isPlane",function(value,element){var tel=/^(\d{3,4}-)\d{7,9}$/g;return this.optional(element)||tel.test(value)},"请正确填写您的联系电话。"),jQuery.validator.addMethod("isTel",function(value,element){var length=value.length,mobile=/^1[3-8]\d{9}$/,tel=/^(\d{3,4}-)\d{7,9}$/g;return this.optional(element)||tel.test(value)||11==length&&mobile.test(value)},"请正确填写您的联系方式"),jQuery.validator.addMethod("notIllegalCharacter",function(value,element){var char=/^[^><\/\\;&]*$/;return this.optional(element)||char.test(value)},"请输入正确的内容"),jQuery.validator.addMethod("isBusinessReg",function(value,element){return this.optional(element)||reg(value)},"请填写正确的工商注册号码"),jQuery.validator.addMethod("diliMethod",function(value,element,param){var me=param,t=window[me].call(this,value,element);return 1!=t?($.validator.messages.diliMethod=t,!1):!0}),jQuery.validator.addMethod("diliPattern",function(value,element,param){var params=param.split("/,"),pa=eval(params[0]+"/"),msg=params[1],t=pa.test(value);return 0==t&&($.validator.messages.diliPattern=void 0!==msg?msg:$.validator.messages[msg]),t}),jQuery.validator.addMethod("isCarNo",function(value,element){var carNO=/^[\u4E00-\u9FA5]{1}[a-zA-Z]{1}[\da-zA-Z]{5}$/;return this.optional(element)||carNO.test(value)},"请输入正确的车牌号码!"),jQuery.validator.addMethod("isAddr",function(value,element){var reg=/[\#\<\>\=\'\"]+/g;
return this.optional(element)||!reg.test(value)},"请输入正确的地址信息!"),jQuery.validator.addMethod("filterCharacter",function(value,element){var char=/^[0-9a-zA-Z\u4e00-\u9fa5/()()&《》【】\+=\]\[]+$/g;return this.optional(element)||char.test(value)},"请输入正确的内容");