2
残りのフィールドでは正常に動作していますが、カスタムバリデーターをチェックボックスの検証サマリの一部として機能させることはできますが、喜びはありません。 ...任意のアイデアチェックボックスValidationSummaryが動作していないカスタムバリデーター
これは私が今
<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>
で持っているものである。しかし、私は、私は私の他のフィールドとは、このチェックボックスのために何のためにエラーメッセージを参照してください提出クリックしたとき?
document.getElementById('<%= optIn.ClientID %><%= optIn.ClientID %>').checked;
変更それに:私は実際にcontroltovalidateを追加することができます
<asp:CustomValidator ID="valTandCs" ClientValidationFunction="ValidateTandCs"
ControlToValidate="optIn" //
ValidationGroup="ValidationSummary1" runat="server"
:
はまた
CustomValidator
ためControlToValidate
プロパティを設定 – StevieBこの行が変更されました。document.getElementById( '<%= optIn.ClientID%>')。checked; でも、検証要約には表示されません。このページはチェックされていなくても検証されます。何か案は ? – StevieB