Get collection of ASP.Net validators in javascript

I'm essentially trying to disable all RequiredFieldValidators on a page using the function ValidatorValidate(id, boolean) however my first step would be to get a collection of all the validators on the page and then filter them down to just the RequiredFieldValidators.

I'd like to do this using javascript only if possible.

Answers


function DisbaleAllValidators() {
    if (typeof Page_Validators != 'undefined') {
        for (i = 0; i < Page_Validators.length; i++) {
            if (Page_Validators[i] != null) {
                ValidatorEnable(Page_Validators[i], false);
            }
        }
    };
}

Update:

According to MSDN docs, you cannot differentiate between the types of validators on the client-side. However, you could try assigning the requiredfieldvalidators a css class - and then checking to see if the validator is of that class. Untested: code:

if ($(Page_Validators[i]).hasClass("classname")) {  
    ValidatorEnable(Page_Validators[i], false);
}

Need Your Help

if statement's not working

php forms if-statement

Forgive my noobness coding as I teach myself PHP (lol)!