ASP.NET: Disable, Enable Validator Using Javascript
Posted by tech on
November 3, 2008
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.









February 16th, 2009 at 1:02 am
Thank you for this post! It was exactly what I needed.
February 16th, 2009 at 1:05 am
hey. welcome. glad it helped you
March 4th, 2009 at 6:38 am
Thnx! It is working perfectly
March 4th, 2009 at 6:41 am
you are welcome. glad it helped you. pls do support this blog by subscribing to the feeds for future tips and tricks