更新时间:2022-12-11 08:45:53
您可以通过执行以下操作来创建一个简单的规则:
You can create a simple rule by doing something like this:
jQuery.validator.addMethod("greaterThanZero", function(value, element) {
return this.optional(element) || (parseFloat(value) > 0);
}, "* Amount must be greater than zero");
然后像这样应用:
$('validatorElement').validate({
rules : {
amount : { greaterThanZero : true }
}
});
只需更改addMethod"的内容即可验证您的复选框.
Just change the contents of the 'addMethod' to validate your checkboxes.