【发布时间】:2013-03-16 18:30:36
【问题描述】:
我正在使用 jQuery Validation 插件来验证复选框,因为它没有默认选项,应该选择一个,最多可以选择两个复选框,这是标准。我没有收到任何错误,也没有验证。我正在扩展它,如下所示,
<input type="checkbox" name="test[]" />x
<input type="checkbox" name="test[]" />y
<input type="checkbox" name="test[]" />z
$("#formid").validate({
rules: {
test[]: {
required: function(elem)
{
return $("input.select:checked").length > 0;
}
},
messages: {
test[]: "You must check at least 1 box"
}
});
【问题讨论】: