开发者

Disable jQuery validation with class = cancel on button not working

jquery.validate.unobtrusive.js

I have two submit buttons Back and Continue, when i am clicking Back i don't want jQuery to validate the form.

Why jQuery validation not canceled when i set class = cancel ?

<button name="submit"开发者_如何学Python class="cancel" value="Back">Back</button>

Any thoughts?

similar thing here jQuery Validation plugin: disable validation for specified submit buttons


There appears to be a bug in the unobtrusive framework. See :http://aspnet.codeplex.com/workitem/7964 They claim that it works if you use the Ajax.BeginForm(...) vs the Html.BeginForm(...), but that did not work for me either. The only way I got it to work was to add this script before any unobtrusive jQuery files like so:

$.validator.setDefaults({
    ignore: ":hidden .ignore" 
});

and you must not use any HttpPostAttribute'ed methods. I don't understand why myself, but it just did not work from me when I used postback methods. =( Hope this helps

REF: http://forums.asp.net/p/1752906/4751939.aspx/1?Re+MVC+3+How+to+bypass+client+side+validation


Can you provide more information about which jQuery plugin are you using at this example?

If you want to reset form, then you can use Validator method resetForm( )

I suggested that you are usign this plugin


If the submit button is part of an Ajax form, there is an issue with jquery.unobtrusive-ajax.js ignoring the cancel class. See http://aspnet.codeplex.com/workitem/7964.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜