3

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 2

2

Add code below right after ValidatorEnable(control, enable) method call:

if (control.style.visibility == "visible") {
     control.style.visibility = "hidden";
} else {
     control.style.display = "none";
}
Sign up to request clarification or add additional context in comments.

Comments

1
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....

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.