We need a custom validator and a small client side javascript
<asp:WizardStep runat="server"
AllowReturn="False">
<asp:CheckBox ID="chkterm"
runat="server"
/>I agree with the Terms and Conditions
<asp:CustomValidator ID="CustomValidatorAgree"
runat="server"
ClientValidationFunction='validatechkbox'
ControlToValidate="txtinterest" ErrorMessage="Please read and agree Terms and Conditions" ValidateEmptyText="True"></asp:CustomValidator>
</asp:WizardStep>< script language="javascript" type="text/javascript"> function validatechkbox(obj, args) {
var controlID1 = '<%= chkterm.ClientID %>';var checkbox = document.getElementById(controlID1); args.IsValid = checkbox.checked;} </script>
Note :Set the ControlToValidate validate property of custom validator to any other controles in the formValidate checkbox inside CreateUserWizard<asp:CreateUserWizard ID="CreateUserWizard1" runat="server">
<asp:CheckBox ID="chkterm" runat="server" /><asp:TextBox runat="server" ID="txtvalidate" Text="I agree with the Terms and Conditions" ReadOnly ="true" Width="250px" ></asp:TextBox><asp:CustomValidator ID="CustomValidatorAgree" runat="server" ClientValidationFunction='validatechkbox'
ControlToValidate="txtvalidate" ErrorMessage="Please read and agree Terms and Conditions" ValidateEmptyText="True" Display="Dynamic" ValidationGroup="CreateUserWizard1" ></asp:CustomValidator>
<script language="javascript" type="text/javascript">
function validatechkbox(obj, args) {
var checkbox = document.getElementById(controlID1);
}</script>
No comments:
Post a Comment