65.9K
CodeProject is changing. Read more.
Home

Enable or Disable ASP.NET Validation on Client Side

starIconstarIconstarIconstarIcon
emptyStarIcon
starIcon

4.96/5 (15 votes)

Oct 5, 2010

CPOL
viewsIcon

50510

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

Thanks,
Imdadhusen