Thursday, February 17, 2011

Disable an ASP.NET validation from Javascript

Below is a small code i used to disable my dotnet validators through javascript
var myVal = document.getElementById('MyvalidatorsClientId');
ValidatorEnable(myVal, false);

where ValidatorEnable(Object, Enabled).

A sample could be
function CountryChanged()
{
var myVal = document.getElementById('ctl00_ContentPlaceHolder1_RfvtxtState');
ValidatorEnable(myVal, false);
}