Enable or Disable ASP.NET Validation on Client Side






4.96/5 (15 votes)
How to enable or disable ASP.NET validation on client side
Introduction
Here is the solution to enable/disable ASP.NET validation using JavaScript.
Scenario: Suppose I have a dropdown which contains a list of Asian countries and Other when user is selecting Other
than only txtOtherCity
is enabled else disable, at that I disable the required field validation for Other
city (rfvOtherCity
).
//Syntax:
ValidatorEnable(ValidatorContronName,Boolean);
//Explanation:
ValidatorContronName:This is ClientID of the Validation control.
Boolean:true(Enable) or false(Disable)
//Example:
ValidatorEnable(document.getElementById('<%=rfvOtherCity.ClientID%>'), false);
Please provide a "Vote" if this would be helpful .
Thanks,
Imdadhusen