jQuery Validation Callback Function

Vincent Catalano picture Vincent Catalano · Jun 3, 2011 · Viewed 24.7k times · Source

I currently have a form within a lightbox frame on my webpage. When a user submits the form with invalid data, a div appears with a list of form errors at the top of the form. The problem is: I need some sort of jQuery validation callback to resize the lightbox after the errors div appears. As far as I'm aware, there is no way to do this with the jQuery lightbox.

Answer

mcgrailm picture mcgrailm · Jun 3, 2011

you to supply the invalid callback function which you can find documented here, like so

$(".selector").validate({
    invalidHandler: function(form, validator) {
        var errors = validator.numberOfInvalids();
        if (errors) {
            //resize code goes here
        }
    }
})