Jacques Jacques - 1 year ago 89
ASP.NET (C#) Question

asp.net disable/enable validator using Javascript

I have a complex form requiring me to switch specific validators on or off depending on selections made by the user.

ValidatorEnable seems to do the job, but it seems that when I call this method it actually fires the validation process as well, without the user actually hitting the submit button.

Is that how it works?

Answer Source

I eventually found the best way to do this was to use the following code:

var validatorObject = document.getElementById('<%=ValidHasShippingLocationZip.ClientID%>');
validatorObject.enabled = false;
validatorObject.isvalid = true;