如何在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)或服务器逻辑,以使字段需要。