How to add a 'submitHandler' function when using jQuery Unobtrusive Validation?

前端 未结 5 1994
-上瘾入骨i
-上瘾入骨i 2020-11-27 13:31

I\'m validating a form using the new unobtrusive validation features in ASP.NET MVC 3.

So there is no code that I have written to setup jQuery validate to start vali

5条回答
  •  一整个雨季
    2020-11-27 13:57

    The unobtrusive library will attach the validator on all forms, so you have to replace the submitHandler this way:

    $("form").data("validator").settings.submitHandler = function (form) { alert('submit'); form.submit(); };
    

提交回复
热议问题