【问题标题】:HTML5 form validation not working in bootstrap modalHTML5 表单验证在引导模式下不起作用
【发布时间】:2018-04-11 19:25:57
【问题描述】:

我在引导模式中有以下表单,但 HTML5 验证无法在其中工作,并在控制台中抛出错误,提示“名称为“移动”的无效表单控件不可聚焦。”

<div id="registermodal1" class="modal register-modal" role="dialog">

<!-- Modal content-->
 <form role="form" class="reg_form">
<div class="modal-content">
  <div class="modal-header vostro-modal-header">
    <button type="button" class="close" data-dismiss="modal">&times;</button>
    <h4 class="modal-title">Register</h4>
  </div>
  <div class="modal-body">

  <div class="row">

      <div class="col-lg-4 col-md-4 col-sm-4 titleSideBar">
        <h5 style="color: #fff;">Create Cavein</h5>
<h5 style="color: #fff;">Account</h5>
<br><br><br><br>
<h5 style="color: #fff;">100% Genuine Owners, 0% Brokerage.</h5><br><br>
<img src="<?php  echo base_url('assets/images/house.png'); ?>">

      </div>
      <div class="col-lg-8 col-md-8 col-sm-8 mainContainer form">

          <div class="control-group">
                    <h6 style="font-size: 16px;color: #fff;padding-bottom: 5px;">Your contact number is necessary for us to verify your identity</h6>


输入您的手机号码。 +91

          </div>
          <br>


      </div>
    </div>


  </div>
  <div class="modal-footer">

    <button class="lof"><div class="loader"></div></button>
    <button type="submit" id="next_1" class="btn btn-next my-btn">Next</button>
  </div>

</div>
 </form>

【问题讨论】:

  • 我没有看到名为 mobile 的表单元素

标签: html twitter-bootstrap


【解决方案1】:

在您的表单中,您可能隐藏了具有必需属性的输入。

<input type="hidden" required />

因此表单无法专注于该元素,您必须从所有隐藏的输入中删除 required。

【讨论】:

    【解决方案2】:

    在表单中添加novalidate 属性会有所帮助:

    <form name="myform" novalidate>
    

    【讨论】:

      猜你喜欢
      • 2015-11-30
      • 2019-05-25
      • 1970-01-01
      • 2023-04-08
      • 1970-01-01
      • 1970-01-01
      • 2017-09-02
      • 2016-07-04
      • 1970-01-01
      相关资源
      最近更新 更多