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

前端之家收集整理的这篇文章主要介绍了twitter-bootstrap-3 – 在Bootstrap中定义一个“required”字段前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
如何在Twitter Bootstrap 3中根据需要定义文本字段(带红色边框)?

required =“必需”不工作…

  1. <form role="form">
  2. <div class="form-group">
  3. <label for="exampleInputEmail1">Email address</label>
  4. <input type="email" class="form-control" id="exampleInputEmail1" placeholder="Enter email">
  5. </div>
  6. <div class="form-group">
  7. <label for="exampleInputPassword1">Password</label>
  8. <input type="password" class="form-control" id="exampleInputPassword1" placeholder="Password">
  9. </div>
  10. <div class="form-group">
  11. <label for="exampleInputFile">File input</label>
  12. <input type="file" id="exampleInputFile">
  13. <p class="help-block">Example block-level help text here.</p>
  14. </div>
  15. <div class="checkBox">
  16. <label>
  17. <input type="checkBox"> Check me out
  18. </label>
  19. </div>
  20. <button type="submit" class="btn btn-default">Submit</button>
  21. </form>

解决方法

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

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

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

猜你在找的Bootstrap相关文章