我编写了一个自定义方法来验证价格是否有效。例如。没有字母等。因此我写了一个自定义方法。但我不知道如何传递价值。
方法:
function checkIsPriceValid(input)
{
alert(input);
return false;
}
表单验证
$(function () {
jQuery.validator.addMethod("checkIsPriceValid", function (value, element) {
return checkIsPriceValid();
//check whether checkbox dist and algo is checked
}, "Invalid number");
$("#addProductForm").validate({
errorPlacement: function (error, element) {
//error.appendTo(element.prev());
error.insertAfter(element);
},
rules: {
productName: {
required: true
},
productCategory:{
required: true
},
productDescription: {
required: true
},
productOrginalPrice:{
required: true,
checkIsPriceValid: this.val()
}