1

enter image description here

Hello, I have to implement a form like above. Apart from other required fields, text boxes near the check boxes are not required to be filled in unless the associated check boxes are checked. How can i implement this. Thanks...

2 Answers 2

1

You can attach an onClick client side JS function and then you can enable/disable the validator via JS.

<asp:CheckBox ID="" runat="server" OnClick="EnableDisable(this,ValidatorID)" />

<script type="text/javascript">
function EnableDisable(checkbox,ValidatorID){
  var myVal = document.getElementById(ValidatorID);
  ValidatorEnable(myVal, checkbox.checked); 
}
</script>
Sign up to request clarification or add additional context in comments.

Comments

0

Try this:

<asp:RequiredFieldValidator ... Enabled=<%# checkBox.Checked %> ... />

Here, you have to set the AutoPostBack property value of the CheckBox to true.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.