$.validator.addMethod("checkText",function(value,element,params){ var reg01 = /^[\u4e00-\u9fa5]+$/; return this.optional(element)||(reg01.test(value)); },"只能输入中文"); $.validator.addMethod("checkMerchantCode",function(value,element,params){ var reg01 = /^[a-zA-Z0-9]+$/; return this.optional(element)||(reg01.test(value)); },"只能输入数字和字母"); $.validator.addMethod("checkPhone",function(value,element,params){ // var checkEmail = /^[a-z0-9]+@([a-z0-9]+\.)+[a-z]{2,4}$/i; var reg01 = /^(0|86|17951)?(13[0-9]|15[0-9]|17[0-9]|18[0-9]|14[0-9]|19[0-9])[0-9]{8}$/; var reg02 = /^(0[0-9]{2,3}\-)([2-9][0-9]{6,7})+(\-[0-9]{1,4})?$/; return this.optional(element)||(reg01.test(value)||reg02.test(value)); },"*请输入正确的手机号或座机号!"); $.validator.addMethod("checkNumber",function(value,element,params){ var reg01 = /^\d+$|^\d+[.]?\d+$/; return this.optional(element)||(reg01.test(value)); },"请正确输入数字"); $.validator.addMethod("checkIdCard",function(value,element,params){ var reg01 = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/; return this.optional(element)||(reg01.test(value)); },"只能输入数字和X"); $.validator.addMethod("checkTaxNo",function(value,element,params){ var reg01 = /^[A-Z0-9]{15}$|^[A-Z0-9]{17}$|^[A-Z0-9]{18}$|^[A-Z0-9]{20}$/; return this.optional(element)||(reg01.test(value)); },"只能输入数字和大写字母、长度只能是15、17、18、20位"); $.validator.addMethod("checkTaxRate",function(value,element,params){ var reg01 = /^(0)(\.[\d]{1,2})?$/; return this.optional(element)||(reg01.test(value)); },"请输入0-1之间的1或2位小数"); $.validator.addMethod("checkTaxRate2",function(value,element,params){ var reg01 = /^(0)(\.[\d]{1,2})?$/; var reg02 = "免税"; return this.optional(element)||(reg01.test(value)||(reg02 == value)); },"请输入0-1之间的1或2位小数,或\"免税\""); $.validator.addMethod("checkInteger",function(value,element,params){ var reg01 = /^[+]{0,1}(\d+)$/; return this.optional(element)||(reg01.test(value)); },"请输入整数");