Click here to Skip to main content
Click here to Skip to main content

Enable or Disable ASP.NET Validation on Client Side

, 2 May 2011
Rate this:
Please Sign up or sign in to vote.
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

License

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

About the Author

Sunasara Imdadhusen
Software Developer (Senior) Infostretch Ahmedabad-Gujarat
India India
Aspiring for a challenging carrier wherein I can learn, grow, expand and share my existing knowledge in meaningful and coherent way.

sunaSaRa Imdadhusen
 
AWARDS:
  1. 1st Best Asp.Net article of SEP 2010
  2. 2nd Best Asp.Net article of MAY 2011
 
Read More Articles...
Follow on   Twitter   Google+   LinkedIn

Comments and Discussions

 
GeneralMy vote of 5 PinmemberSavalia Manoj M7-Nov-12 1:10 
GeneralRe: My vote of 5 PinpremiumSunasara Imdadhusen22-Apr-14 3:10 
QuestionDefinition of ValidatorEnable? Pinmembertahir.h4-Oct-12 2:35 
AnswerRe: Definition of ValidatorEnable? PinmemberSunasara Imdadhusen4-Oct-12 2:59 
GeneralThanks, this is not appreciation! PinmemberSunasara Imdadhusen22-Aug-11 16:57 
GeneralReason for my vote of 1 to short. I would have preferred an... PinmemberMohammad_Denmark22-Aug-11 3:15 
GeneralRe: Reason for my vote of 1to short. I would have preferred an... PinpremiumSunasara Imdadhusen22-Apr-14 3:10 
GeneralThanks for finding bug. PinmemberSunasara Imdadhusen2-May-11 22:55 
GeneralHi Sunasara, Fix the typo in last line of the code Validator... Pinmvpthatraja5-Mar-11 1:24 
GeneralRe: Hi Sunasara,Fix the typo in last line of the codeValidator... PinpremiumSunasara Imdadhusen22-Apr-14 3:11 
GeneralRe: Hi Sunasara,Fix the typo in last line of the codeValidator... Pinprotectorthatraja22-Apr-14 3:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web03 | 2.8.140721.1 | Last Updated 3 May 2011
Article Copyright 2010 by Sunasara Imdadhusen
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid