<pre name="code" class="javascript">jQuery.validator.addMethod("carNumber", function(value,element){
var carNumber = value;
var reg = /^[\u4e00-\u9fa5]{1}[a-zA-Z]{1}[A-Z_0-9]{5}$/;
return carNumber.search(reg)!=-1 || carNumber=="";
},"please enter a vaild carNumber");
jQuery("#form1").validate({
rules : {
'phone' : {"required":true},
'carNumber' : {"required":true,"carNumber":true}
},
messages : {
'phone' : {"required":"请选择客户手机号码"},
'carNumber' : {"required":"请输入车牌","carNumber":"车牌格式不正确"}
}
});
jQuery.validator 自定义验证
最新推荐文章于 2022-11-15 10:26:35 发布