1
如何使用addMethod()方法编写新方法?我想验证一个电话号码,它以0开始,它的长度是10。我试过到目前为止:添加方法jQuery验证
function cell(element, value){
if (!/^[0]\d{9}$/.test(element).val()) {
return false;
}
else {
return true;
}
}
$.validator.addMethod("cell", cell, "This phone number is incorrect");
和:
$("#signupForm").validate({
rules: {
cell: {
required: true,
digits: true,
cell: true
}
}
})
而在消息我应该在写'cell'的消息给?谢谢!
[自定义方法与jQuery验证插件]的可能重复(http://stackoverflow.com/questions/15589152/custom-method-with-jquery-validation-plugin) –