问题描述
正如主题所暗示的,我正在使用bassistance.de验证插件(http://docs.jquery.com/Plugins/Validation/),即使存在验证错误,我也希望能够提交表单.基本上,我们只希望使用该插件来警告用户潜在的问题(请知道,对此请不要质疑可用性问题.)
as the subject suggests, I am using the bassistance.de validation plugin (http://docs.jquery.com/Plugins/Validation/) and I would like to be able to submit the form even when there are validation errors. Basically, we only want to use the plug-in to warn the user of potential issues (please don't question the usability issues with this , I know).
那么,有没有一种方法可以轻松实现呢?还是我应该破解插件代码?
So, is there a way to do it easily or should I hack into the plugin code?
提前谢谢!
推荐答案
我不会质疑与此有关的可用性问题:).通过使用invalidHandler
选项进行验证,确实可以实现:
I will not question the usability issues around this :).This is indeed possible by using the invalidHandler
option for validate:
$("#test-form").validate({
invalidHandler: function() {
/* Allow the user to see the error messages before submitting: */
window.setTimeout(function() {
$("#test-form")[0].submit();
}, 1000);
}
});
这里是一个示例: http://jsfiddle.net/ghDbd/
这篇关于jQuery验证插件:如何将错误视为警告并允许表单提交?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!