【发布时间】:2011-01-25 19:01:28
【问题描述】:
我有以下验证,在我的其他字段中运行良好,但试图让自定义验证器作为复选框验证摘要的一部分但没有乐趣。
这是我目前拥有的
<script language="javascript" type="text/javascript">
function ValidateTandCs(source, args)
{
args.IsValid = document.getElementById('<%= optIn.ClientID %>').checked;
}
</script>
<asp:ValidationSummary CssClass="highlight"
id="ValidationSummary1"
HeaderText="<p>Please amend these errors below to continue with your
application.</p>" Runat="server" />
<asp:CheckBox id="optIn" runat="server"></asp:CheckBox> I agree to the terms and
conditions of this site and I wish to Opt In for registration.
<asp:CustomValidator ID="valTandCs" ClientValidationFunction="ValidateTandCs"
ValidationGroup="ValidationSummary1" runat="server"
ErrorMessage="Please accept Terms and Conditions before submitting.">
</asp:CustomValidator>
但是当我点击提交时,我只看到我的其他字段的错误消息,而这个复选框什么也没看到...有什么想法吗?
【问题讨论】:
标签: asp.net checkbox customvalidator