jQuery验证插件submitHandler延迟表单提交

时间:2013-08-04 08:29:02

标签: jquery forms post jquery-validate

我正在使用jQuery Validate插件的submitHandler来禁用提交按钮,但是一旦表单提交按钮被禁用,我必须等待好5到10秒才能将表单发布到其他页面?整码下面,很奇怪?这可能是超时的事情吗?

                          
        <script src="http://code.jquery.com/jquery-1.7.2.js" type="text/javascript"></script>
        <script src="http://jquery.bassistance.de/validate/jquery.validate.js"></script>
        <script src="http://jquery.bassistance.de/validate/additional-methods.js"></script>   

        <script>

        $( "#UploadForm" ).validate({

  errorLabelContainer: "#messageBox",
  wrapper: "td",

  rules: {  

   name: {
        required: true
         }

  },
  submitHandler: function (form) {

   $('#submit').attr('disabled','disabled');
   form.submit();

}

});
        </script>

1 个答案:

答案 0 :(得分:11)

$('#UploadForm').submit();会触发另一轮验证(&#34;过多的递归错误&#34;此处记录:http://jqueryvalidation.org/documentation/

试试这个:

submitHandler: function (form) {
   $('#submit').attr('disabled','disabled');
   form.submit();
}