首页 > 语言 > JavaScript > 正文

jquery submit()不能提交表单的解决方法

2024-05-06 15:18:06
字体:
来源:转载
供稿:网友

 今天写表单提交的时候需要增加一个确认提示,所以没有使用submit按钮提交,改用jq的submit(),然后问题了

<form class="form-horizontal m-t" method="post" action="@Url.Action("Edit")" id="form">    <div class="row">      <div class="col-sm-12">        <div class="ibox float-e-margins">          <div class="ibox-title">            <h5>添加</h5>          </div>          <div class="ibox-content">            <div class="form-group">              <label class="col-sm-3 control-label">开始时间:</label>              <div class="col-sm-8">                <span>                  @(Model.annualRate_beginDate?.ToString("yyyy-MM-dd"))                </span>              </div>            </div>            <div class="form-group">              <label class="col-sm-3 control-label">结束时间:</label>              <div class="col-sm-8">                <input type="text" class="form-control" name="annualRate_endDate" id="annualRate_endDate" onclick="laydate({ istime: false, format: 'YYYY-MM-DD' })" value="@Model.annualRate_endDate.ToString("yyyy-MM-dd")" required>              </div>            </div>            <div class="form-group">              <label class="col-sm-3 control-label">年利息%:</label>              <div class="col-sm-8">                <input type="number" step="0.01" class="form-control" id="annualRate_rate" name="annualRate_rate" value="@Model.annualRate_rate.ToString("#0.00")" required>              </div>            </div>            <div class="form-group">              <div class="col-sm-4 col-sm-offset-2">                <button class="btn btn-lg btn-primary" id="submit_btn" type="button">                  提交                </button>                <a class="btn btn-lg btn-white" href="@Url.Action(" rel="external nofollow" Index")">                  取消                </a>              </div>            </div>          </div>        </div>      </div>    </div>  </form>
<script type="text/javascript">  $(function () {    $("#submit").click(function () {      var start = '@(Model.annualRate_beginDate?.ToString("yyyy-MM-dd"))';      var end = $("#annualRate_endDate").val();      var val = $("#annualRate_rate").val();      layer.confirm('请确认所填写的信息是否正确?<br/>开始时间:' + start + '<br/>结束时间:' + end + '<br/>年利率:' + val, { icon: 3, title: '提示' }, function (index) {        $("#form").submit();        layer.close(index);      });    });  })</script>

点击提交按钮出现确认提示,但是确认后就没反应了

但是将button的type改为submit却又能提交

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表

图片精选