jQuery.validator 验证手机号码与座机号码

jQuery.validator.addMethod("isPhone", function(value,element) { var length = value.length; var mobile =/^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1})|(14[0-9]{1})|(17[0-9]{1}))+\d{8})$/; var tel = /^\d{3,4}-?\d{7,9}$/; if(/-/.test(value)){ return this.optional(element) || tel.test(value); }else{ return this.optional(element) || (length == 11 && mobile.test(value)); }}, "请正确填写您的联系电话");

    推荐阅读