I want my validation control to be enable/disable with javascript. When I click on radiobutton list(yes/no), 2-3 rows becomes visible. Once Yes is clicked, then and only then user has to enter input for the textbox provided in that rows. For this I have kept require field validators. I am disabling all of them on page load and again enabling in javascript using ValidatorEnable(control, enable). But in this case, when ever I click on radio button list the rows becomes visible and at the same time validation control shows error message. I want error message to be seen on the submit button click only. Till then no message should appear. How can I do so..?
2 Answers
function HasPageValidators() {
var hasValidators = false;
try {
if (Page_Validators.length > 0) {
hasValidators = true;
}
}
catch (error) {
}
return hasValidators;
}
function ValidationGroupEnable(validationGroupName, isEnable) {
if (HasPageValidators()) {
for (i = 0; i < Page_Validators.length; i++) {
if (Page_Validators[i].validationGroup == validationGroupName) {
ValidatorEnable(Page_Validators[i], isEnable);
}
}
}
}
Then call:
ValidationGroupEnable('validationgroup', false);
i think it will help you....