且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

jQuery验证插件:如何将错误视为警告并允许表单提交?

更新时间:2021-07-10 23:27:11

我不会质疑与此有关的可用性问题:). 通过使用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/