前端验证

var myCheck = {
regPhone: /^(13[0-9]|14[5|7]|15[0|1|2|3|5|6|7|8|9]|18[0|1|2|3|5|6|7|8|9])d{8}$/,
regTel: /d{3}-d{8}|d{4}-d{7}/,
regID: /^d{8,18}|[0-9x]{8,18}|[0-9X]{8,18}?$/,
regChinese: /[u4e00-u9fa5]/,
regTelCom: /[1-9]d{5}(?!d)/,
regEmail: /^w+([-+.]w+)*@w+([-.]w+)*.w+([-.]w+)*$/,
regPositiveFloat2: /^[0-9]+(.[0-9]{2})?$/,
regPositiveInt: /^[1-9]d*$/,
regNegtiveInt: /^-[1-9]d*$/,
isEmpty: function (input) {
if (input===undefined||input===null||input==="") {
return true;
} else {
return false;
}
},
isType: function (type, input) {
if (this.isEmpty(input)) {
return false;
} else {
return type.test(input);
}
},
isPhone: function (input) {
return this.isType(this.regPhone, input);
},
isEmail: function (input) {
return this.isType(this.regEmail, input);
},
isPositiveInt: function (input) {
return this.isType(this.isPositiveInt, input);
},
isPositiveFloat2: function (input) {
return this.isType(this.isPositiveFloat2, input);

},
}

原文地址:https://www.cnblogs.com/tangsh/p/5095124.html