views:

19

answers:

1

How can I display multiple validation summaries at one time? I currently have three different validation groups on a page for different sections of the page. Basically, the first section should be validated by one validation group, the second section should validate both the the first and section section and the third should validate all three.

I've got the following javascript which validates properly, but only the last validation summary is visible, the first two don't appear (but the red asterisks next to the controls do appear).

function ValidateSection3() {
    var validated = Page_ClientValidate("vgSection1");
    if (validated) {
        validated = Page_ClientValidate("vgSection2");
        if (validated)
            validated = Page_ClientValidate("vgSection3");
    }
    return validated;
}

Is there any way to validate all three groups and show the summaries for all three?

Thanks!!

A: 

I've figured it out. Here's what I did in case anyone stumbles on this question.

function ValidateSection3() {   
    var isSection1Validated = Page_ClientValidate("vgSection1");
    var isSection2Validated = Page_ClientValidate("vgSection2");
    var isSection3Validated = Page_ClientValidate("vgSection3");

    for (i = 0; i < Page_ValidationSummaries.length; i++) {
        if (Page_ValidationSummaries[i].validationGroup.toString() == "vgSection1") {
            if (!isSection1Validated) {
                Page_ValidationSummaries[i].style.display = "";
            }
        }
        else if (Page_ValidationSummaries[i].validationGroup.toString() == "vgSection2") {
            if (!isSection2Validated) {
                Page_ValidationSummaries[i].style.display = "";
            }
        }
        else if (Page_ValidationSummaries[i].validationGroup.toString() == "vgSection3") {
            if (!isSection3Validated) {
                Page_ValidationSummaries[i].style.display = "";
            }
        }
    }
    return isSection1Validated && isSection2Validated && isSection3Validated;
}
Chris Conway