Reputation: 163
Can anyone tell me what is the best way to disable validator control using JavaScript?
Which one is the best way to dsiable validation control(considering compatability as well)? Any help is greatly appreciated.
1]
var validatorObject = document.getElementById('<%=ValidatorControl.ClientID%>');
ValidatorEnable(validatorObject , true);
2]
var validatorObject = document.getElementById('<%=ValidatorControl.ClientID%>');
validatorObject.enabled = false;
Thanks.
Upvotes: 1
Views: 763
Reputation: 4904
When you call ValidatorEnable(val, enable) it calls a function that looks like this:
(to see it open the WebRescouce.axd
script)
function ValidatorEnable(val, enable) {
val.enabled = (enable != false);
ValidatorValidate(val);
ValidatorUpdateIsValid();
}
By just enabling/disabling the validator(line 3), you can achieve what you want.
Also, calling ValidatorEnable
which further calls ValidatorUpdateDisplay
will immediately validate the associated control and show any validation messages.
According to me rather than using multiple js calling better would be using
var validatorObject = document.getElementById('<%=ValidatorControl.ClientID%>');
validatorObject.enabled = false;
which simply serve's your purpose of enabling/disabling the validator...
Reference Help
Upvotes: 1