Skip to content Skip to sidebar Skip to footer

Get A Event From Asp.net's Validators To Jquery On Status Change

i would like to have an event fired in jquery, if the validators of my page change their states. This is my usecase: In an Adressform the Validators all are hidden. If i submit th

Solution 1:

Here is how you can call .NET validators from JavaScript: Manually calling ASP.NET Validation with JavaScript You could integrate the above with jQuery events or jQuery Validation.

NOTE: This solution is if you are tied to .NET Validators, otherwise just use jQuery Validation as Dave mentioned.

Solution 2:

Have you looked into the standard jQuery validator plugin? I'm pretty sure its validators have events you can hook into in just the way you describe.

Solution 3:

Sorry for answering this old question, but I made a blog post about modifying the default javacscript evaluation function of the ASP.NET validators. Basically it comes down to this:

for (var i = 0; i < window.Page_Validators.length; i++) {
    // Create a new property and assign the original evaluation function to itwindow.Page_Validators[i].baseEvaluationFunction = window.Page_Validators[i].evaluationfunction;

    // Set our own validation functionwindow.Page_Validators[i].evaluationfunction = evaluateField;
}

Next, in the 'evaluateField' function, write the code to set the css.

functionevaluateField (validator) {
    // Run the original validation functionvar isvalid = validator.baseEvaluationFunction(validator);

    // Handle the resultif (isvalid) {
        clearError(validator);
    } else {
        setError(validator);
    }

    // Return resultreturn isvalid;
}

In the setError and clearError functions you can use jquery to find the parent row and apply css to it. Hope this helps!

Post a Comment for "Get A Event From Asp.net's Validators To Jquery On Status Change"