小编Mod*_* MV的帖子

jquery验证仅验证第一个字段 - 其他字段将被忽略

我正在使用一个jQuery验证插件,它应该验证表单中的所有输入,但它会在第一个时停止.如果你点击第二个输入并将其留空 - 一切正常 - 它验证...
否则 - 不...

我找到了一些相同的答案 - 没有成功......

这是我写的例子的小提琴

FiddleError

//
//  jQuery Validate example script
//
//  Prepared by David Cochran
//
//  Free for your use -- No warranties, no guarantees!
//

$(document).ready(function(){

// Validate
// http://bassistance.de/jquery-plugins/jquery-plugin-validation/
// http://docs.jquery.com/Plugins/Validation/
// http://docs.jquery.com/Plugins/Validation/validate#toptions

    $('.validate').validate({
        highlight: function(element) {
            $(element).parent().removeClass('has-success').addClass('has-error');
        },
        success: function(element) {
            element.closest().removeClass('has-error').addClass('has-success');
        }
  });

}); // end document.ready`enter code here`
Run Code Online (Sandbox Code Playgroud)

使用:

  • 引导
  • jQuery的
  • jQuery验证

forms jquery jquery-validate twitter-bootstrap

5
推荐指数
1
解决办法
3298
查看次数