Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / web / ASP.NET

Enable or Disable ASP.NET Validation on Client Side

4.96/5 (19 votes)
2 May 2011CPOL 50.5K  
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).

JavaScript
//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 helpfulRose | [Rose] .

Thanks,
Imdadhusen

License

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