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

how to display tags like <?php ?> <script> as text, and <a> as link <table> as table?

php html mysql

I have a variable in PHP that is a string containing HTML. I would like to use the structure of the table and links inside this string, but everything else I would like to escape so it is displayed...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.