加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

twitter-bootstrap-3 – 在Bootstrap中定义一个“required”字段

发布时间:2020-12-18 00:01:56 所属栏目:安全 来源:网络整理
导读:如何在Twitter Bootstrap 3中根据需要定义文本字段(带红色边框)? required =“必需”不工作… form role="form" div class="form-group" label for="exampleInputEmail1"Email address/label input type="email" class="form-control" id="exampleInputEmai
如何在Twitter Bootstrap 3中根据需要定义文本字段(带红色边框)?

required =“必需”不工作…

<form role="form">
  <div class="form-group">
    <label for="exampleInputEmail1">Email address</label>
    <input type="email" class="form-control" id="exampleInputEmail1" placeholder="Enter email">
  </div>
  <div class="form-group">
    <label for="exampleInputPassword1">Password</label>
    <input type="password" class="form-control" id="exampleInputPassword1" placeholder="Password">
  </div>
  <div class="form-group">
    <label for="exampleInputFile">File input</label>
    <input type="file" id="exampleInputFile">
    <p class="help-block">Example block-level help text here.</p>
  </div>
  <div class="checkbox">
    <label>
      <input type="checkbox"> Check me out
    </label>
  </div>
  <button type="submit" class="btn btn-default">Submit</button>
</form>

解决方法

在Bootstrap 3中,可以将一个“验证状态”类应用于父元素: http://getbootstrap.com/css/#forms-control-validation

例如,has-error将在输入周围显示一个红色边框。然而,这将不会对实地的实际验证产生影响。您需要添加一些其他客户端(javascript)或服务器逻辑,以使字段需要。

演示:http://bootply.com/90564

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读