I have a drop down (dropdown2) that is required IF there is something in it but it’s options data is driven by ajax from another dropdown (dropdown1) selection. Sometimes dropdown2 will be empty and in that case I can’t require it. So I can disable the requiredFieldValidators in javascript by calling this…
ValidatorEnable(document.getElementById(validatorId), false);
This works fine but the server still fires the requiredFieldValidator logic. Is anyone aware of how I can force the server to not validate if the validator is set to false client side?
Why don’t you just use a client side validator? You are making your job much more difficult doing this. If you have access to it via the clientside, why are you bothering hitting it at the serverside?
The only other thing I can think of is to create a hidden field and set it via the client side, and then when you do a postback to check this value and disable / enable the validator.
For example after this:
JS:
Then in your load event:
Take a look at this post, very similiar to yours: ASP.NET – how to stop unrequired server validation