一个复选框只能正常工作。但是如何在 - >中的validate()函数中定义3个不同的复选框组。组:{checks:“”}
这是我的代码
$(document).ready(function () {
$("#item").validate({
rules: { //some rules
},
groups: {
checks: "withe blue red",
checks: "gas tel sat",
checks: "cola fanta sprite"
},
messages: { //some messages
}
});
$.validator.addMethod('loc-sel-3', function (value) {
return $('.char-sel-3:checked').size() > 2;
}, '<?php _e("Please check at least 3 characteristic", "twitter"); ?>');
$.validator.addMethod('char-sel-3', function (value) {
return $('.char-sel-3:checked').size() > 1;
}, '<?php _e("Please check at least 2 features", "twitter"); ?>');
$.validator.addMethod('tech-sel-3', function (value) {
return $('.tech-sel-3:checked').size() > 0;
}, '<?php _e("Please check at least one box", "twitter"); ?>');
});
答案 0 :(得分:0)
我找到了解决方案。不同的名字。
群组:{color:“white blue red”,tech:“gas tel sat”,饮料:“cola fanta sprite”},