//validator 扩展
jQuery.validator.addMethod("mail", function(value, element, messages) {
return this.optional(element) || /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(value);
}, "请输入合法邮箱");
jQuery.validator.addMethod("telephone", function(value, element, messages) {
return this.optional(element) || /^(0|86|17951)?(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/.test(value);
}, "请输入正确手机号码");
jQuery.validator.addMethod("tel", function(value, element, messages) {
return this.optional(element) || /^(^0\d{2}-?\d{8}$)|(^0\d{3}-?\d{7}$)|(^0\d{2}-?\d{7}$)|(^0\d{3}-?\d{8}$)|(^400-?\d{7}$)|(^400-?\d{3}-?\d{4}$)|(^400\d{1}-?\d{6}$)|(^400\d{1}-?\d{3}-?\d{3}$)|(^\(0\d{2}\)-?\d{8}$)|(^\(0\d{3}\)-?\d{7}$)$/.test(value);
}, "请输入正确电话号码");
$.validator.addMethod("urlTest",function(value,element,messages){
var r=/^((http|https|ftp):\/\/)?(\w(\:\w)[email protected])?([0-9a-z_-]+\.)*?([a-z]{2,6}(\.[a-z]{2})?(\:[0-9]{2,6})?)((\/[^?#<>\/\\*":]*)+(\?[^#]*)?(#.*)?)?$/i;
return r.test(value);
},"请输入正确的网址");
});