Call a script after validation with jquery.validate.unobtrusive

I am using ASP.NET MVC 3 with unobstrusive 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. Wich 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.


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?

链接地址: http://www.djcxy.com/p/54144.html

上一篇: 为什么使用staticmethod而不是装饰器?

下一篇: 用jquery.validate.unobtrusive进行验证后调用脚本