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

jQuery验证插件:如何将错误视为警告并允许表单提交?,jquery,validation,jquery-plugins,jquery-validate,Jquery,Validation,Jquery Plugins,Jquery Validate,正如主题所示,我正在使用basistance.de验证插件(http://docs.jquery.com/Plugins/Validation/)我希望能够在有验证错误的情况下提交表单。基本上,我们只想使用插件来警告用户潜在的问题(我知道,请不要用它来质疑可用性问题) 那么,有没有一种方法可以很容易地做到这一点,或者我应该侵入插件代码 提前谢谢 我不会质疑这方面的可用性问题:)。 通过使用invalidHandler选项来验证: $("#test-form").validate({ in

正如主题所示,我正在使用basistance.de验证插件(http://docs.jquery.com/Plugins/Validation/)我希望能够在有验证错误的情况下提交表单。基本上,我们只想使用插件来警告用户潜在的问题(我知道,请不要用它来质疑可用性问题)

那么,有没有一种方法可以很容易地做到这一点,或者我应该侵入插件代码


提前谢谢

我不会质疑这方面的可用性问题:)。 通过使用
invalidHandler
选项来验证:

$("#test-form").validate({
    invalidHandler: function() {
        /* Allow the user to see the error messages before submitting: */
        window.setTimeout(function() { 
            $("#test-form")[0].submit();
        }, 1000);
    }
});

下面是一个示例:

我遇到了类似的问题,我决定使用options.ignore属性。

我使用自定义验证器来计算字数。我们决定在X个单词(他们要求的字数)后显示一个错误,如果他们有X+T单词,则不允许表单提交。当X和X+T单词之间存在时,我会向元素添加一个类“error ok”(其中“.error ok”是我作为忽略选项传递的内容)

jQuery.validator.addMethod(“单词计数”,函数(值,元素,最大值){
var公差=0;
if(阵列的最大实例数){
公差=最大值[1];
max=max[0];
}
var typedWords=jQuery.trim(value).split(“”).length;

如果(typedWords,谢谢Andrew,尽管您添加的超时不是必需的,
invalidHandler
似乎是实现此功能的属性!
$("form").validate({
  rules: {
    "hard": {word_count:10}, // No more than 10 words
    "soft_and_hard": {word_count:[30,10]} // No more than 40 words
  },
  ignore: ".error-okay"
});
jQuery.validator.addMethod("word_count", function(value, element, max) {
    var tolerance = 0;
    if (max instanceof Array){
        tolerance = max[1];
        max = max[0];
    }
    var typedWords = jQuery.trim(value).split(' ').length;

    if(typedWords <= max + tolerance) $(element).addClass("error-okay");
    else $(element).removeClass("error-okay");

    return (typedWords <= max);
}, function(max, ele){
    var tolerance = "";
    if (max instanceof Array){
        tolerance = "<br/>Definitly no more than " + ( max[0] + max[1] ) + " words.";
        max = max[0];
    }
    return "Please enter " + max +" words or fewer. You've entered " +
            jQuery.trim($(ele).val()).split(' ').length + " words." + tolerance;
});