asp.net - Checkbox Custom Validator with ValidationSummary not working -


i have following validation working fine rest of fields, trying custom validator work part of validation summary checkbox no joy.

this have @ moment

<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 continue           application.</p>" runat="server" />  <asp:checkbox id="optin" runat="server"></asp:checkbox> agree terms ,                 conditions of site , wish opt in registration. <asp:customvalidator id="valtandcs" clientvalidationfunction="validatetandcs"       validationgroup="validationsummary1" runat="server"       errormessage="please accept terms , conditions before submitting."> </asp:customvalidator> 

but when click submit see error messages other fields , nothing checkbox...any ideas ?

you had in code:

 document.getelementbyid('<%= optin.clientid %><%= optin.clientid %>').checked; 

change to:

 document.getelementbyid('<%= optin.clientid %>').checked; 

also set controltovalidate property customvalidator:

<asp:customvalidator id="valtandcs" clientvalidationfunction="validatetandcs"   controltovalidate="optin" //  validationgroup="validationsummary1" runat="server"  

Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -