Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide a validator's error text when the validator is initially enabled

I've got the following javascript code, which enables a bunch of validators.

ValidatorEnable(document.getElementById("<%=AddressValidator.ClientID %>"), true);
ValidatorEnable(document.getElementById("<%=CityValidator.ClientID %>"), true);
ValidatorEnable(document.getElementById("<%=CountryValidator.ClientID %>"), true);

My problem is that when the validators are enabled with the above code, the error message (i.e. the validation text) is displayed. How can I hide the error message just for this instance when they're being enabled?

like image 345
Dot NET Avatar asked Nov 29 '22 15:11

Dot NET


1 Answers

If you want to enable it without validating:

document.getElementById("<%=AddressValidator.ClientID %>").enabled = true;

Because ValidatorEnable internally looks like:

function ValidatorEnable(val, enable) { 
    val.enabled = (enable != false); 
    ValidatorValidate(val); 
    ValidatorUpdateIsValid(); 
}

http://sandblogaspnet.blogspot.de/2009/04/calling-validator-controls-from.html

like image 170
Tim Schmelter Avatar answered Dec 09 '22 17:12

Tim Schmelter