Call a script after validation with jquery.validate.unobtrusive
Asked Answered
C

1

7

I am using ASP.NET MVC 3 with unobtrusive validate JavaScript. I am also using jQuery UI tabs, and I would like to select a tab who contains an element with an invalid message.

So, to do that I need to call a script just after the jquery.validate is evaluated.

I tried some like this:

$(':submit').submit(function () {
    var invalidField = $(".input-validation-error");
    if (invalidField ) {
        tabid = //some script to detect wich tab contains the invalidField
        $('#someTabed').tabs('select', tabid));
    }
});

It works, but just if I click the submit button TWICE. Which means this method is not called after the event I would like.

So I need to know how to intercept the validate method made by unobtrusive validate, to put my method after that.

Croquette answered 30/7, 2011 at 2:27 Comment(0)
L
4

I don't think you can intercept the method (I could be wrong but all the postings I've ever seen on this all manually call this.valid), instead you will have to call the validation yourself on post.

How to hook into error of jQuery validate unobtrusive in MVC 3?

Lentiginous answered 30/7, 2011 at 12:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.