37 sites, 19,934 entries and counting...     Get a free blog; Join a Weblog Network!
Top

ASP.NET: Disable, Enable Validator Using Javascript

January 9, 2009

Doing this is pretty easy, if you know how or what method to use. I wanted to disable a Validator for a province TextBox if the country DropDownList chosen is USA because the state DropDownList will be enabled so the province should be inactive. Doing this server-side may be easy, but I wanted to use client-side Javascript so that no request will be sent whenever the OnChange event of the country’s DropDownList gets fired. Luckily, there is already a pre-made function in Javascript that disables Validators.

provinceValidator = document.getElementById(’ProvinceValidator’);
ValidatorEnable(provinceValidator, false);

Just set the second parameter as either true or false to enable and disable a Validator. I hope this will help those who have no clue how to go about it like I did until I found out about this function.

Comments

2 Responses to “ASP.NET: Disable, Enable Validator Using Javascript”

  1. Kyawt on June 11th, 2009 11:10 am

    Thanks you very much for this post. It helps me out.

  2. sharmabhabho on February 25th, 2010 6:37 am

    Thank you for sharing information. Lots of detailed sessions are going to take place on Java in the upcoming Suntech Days Conference in Hyderabad on March on 24-25 March. lets see what happens there.

Got something to say?





Credit Counseling - Arizona Landscaping - Debt Consolidation - Renegade Motorhomes
Bottom