In web projects there are many situations when you have to disabled the validator of asp.net control depending on the state of the checkbox, if check box is checked then you can disabled the validor and when check box is unchecked then you can enabled the validator. Here is the main form of the test example which consist of a drop down list control , checkbox and two button one for save and other one for cancel. You can see that check box is checked and the drop down list control is displayed, which is the default behaviour.
Now when check box in unchecked then text box is displayed and the validator control for the dopdown list control is disabled and the validator for the text box is endabled. And also dropdown list control is not hide and the text box control is displayed you can see this behaviour in the image below.
Here is the simple java script which is used to hide and show the control and also to enabled disabled the validators. Here I have used the enabled property of the validator , I set the value to true when the corresponding control is shown and set false when the corresponding control is not hidden.
All and any comments / bugs / suggestions are welcomed!