当验证触发时,1000hz Bootstrap验证器不会提交 - Laravel

时间:2018-05-25 08:32:09

标签: jquery forms laravel-5 form-submit bootstrapvalidator

Bootstrap验证器表单在所有验证错误更正后都没有提交,但如果没有触发验证,表单可以提交,这是我的表格:

{!! Form::open(["method" => "POST", "action" => "user\UserWalletController@transfer", "id" => "transferModal", "class" => "modal fade", "aria-labelledby" => "transferModal", "aria-hidden" => "true"]) !!}
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
        <h5 class="modal-title colorOrange1">Transfer</h5>
      </div>
      <div class="modal-body">
        ...
        <div class="row">
          <div class="col-xs-12">
            <div class="form-group">
              <div class="checkbox checkbox-primary">
                {!! Form::checkbox("agreeTermsOfUse", null, null, ["id" => "termsOfUse", "data-error" => "You must agree Terms of Use", "required"]) !!}
                <label for="termsOfUse"> I agree with Terms Of Use </label>
                <div class="help-block with-errors"></div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-info" data-dismiss="modal">Close</button>
        <button type="submit" id="submitTransferDetails" class="btn bgTeal1" name="operationBtn" value="transferFund">Submit</button>
      </div>
    </div>
    <!-- /.modal-content -->
  </div>
{!! Form::close() !!}

这是我的表单验证函数是JS:

$('#transferModal').validator();

我这样更新了我的代码,它会提交表单,但是它会占用1000个控制台日志,然后才出现错误并提交,为什么会这样???

$('#transferModal').validator().on('submit', function (e) {
  if ($("input[name='transferPasswordStatus']").val() == "true") {
    if (e.isDefaultPrevented()) {
      // handle the invalid form...
    } else {
      console.log("eooer");
      $(this).submit();
    }
  }
  else if ($("input[name='transferPasswordStatus']").val() == "false") {
    alert("Password mismatch");
  }
});

这里是printscreen:

enter image description here

我已经测试了几次,提交按钮名称也没有“提交”,但它根本就没有提交。

问题是什么,如何解决?

1 个答案:

答案 0 :(得分:0)

你有没有试过启用验证,没有js?

就像那样:

<form role="form" data-toggle="validator">
  ...
</form>