Click here to Skip to main content
14,430,298 members
Rate this:
Please Sign up or sign in to vote.
See more:
I have 2 option buttons and a submit button. A comment(a text box) must be provide if option A is selected. How can I disable the validation when Option B is selected?

I read on that you can override the Validate method of the Page and switch it off from there but that didn't seem to work for me, didn't go into my break point.

protected override void Validate()
    this.rfvComment.Enabled = this.optDecline.Checked;

Does anyone have any ideas how I can achieve this or why the above code isn't working?
Sunasara Imdadhusen 28-Oct-10 2:36am
Are you using ASP.Net validation control?

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1


Enable or Disable ASP.Net Validation on client side
rfvOther: is a Required Field Validator
//Explanation:ValidatorContronName – This is ClientID of the Validation control.
Boolean - true(Enable) / false(Disable)
ValidatorEnable(document.getElementById('<%=rfvOther.ClientID%>'), fale);

You can implement this function according you logic.

Please do let me know, if you have any doubt.

Please provide "Vote" if this would be helpful, and make "Accept Answer" if this would be correct answer.:rose:

Sandeep Mewara 28-Oct-10 3:30am
Comment from OP:

Yes, I using a RequiredFieldValiator. Where would you call ValidatorEnable()?
Dalek Dave 28-Oct-10 3:45am
Good Call.
Sunasara Imdadhusen 28-Oct-10 4:19am
Provide your code snippet, wherever you want required to enable/disable like button click or anything else

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100