我正在使用自定义验证器和 jquery 验证复选框列表来检查所需的验证,它的验证很好,但它没有关注错误。
CheckBoxList 和 CustomValidator 的 asp.net 是:
<asp:CheckBoxList ID="cblSellerCategories"
runat="server"
RepeatDirection="Horizontal">
</asp:CheckBoxList>
<asp:CustomValidator ID="CustomValidator2"
runat="server"
ClientValidationFunction="CheckSellerCategory"
CssClass="errorBox"
ErrorMessage="Select seller type"
SetFocusOnError="True">
</asp:CustomValidator>
而jQuery是
function CheckSellerCategory(sender, args) {
args.IsValid = false;
$("[id$='cblSellerCategories']").find(":checkbox").each(function () {
if (jQuery(this).attr("checked")) {
args.IsValid = true;
return;
}
});
}
如何关注错误(如果未选中任何复选框)。我也尝试过验证组,但没有运气。