如何在bootstrap

时间:2018-03-02 08:56:48

标签: twitter-bootstrap twitter-bootstrap-3

我为表单使用bootstrap,如果验证失败则显示错误。下面是一段代码。我想将用户名min和max length分别设置为6和16。如果输入值不符合验证,则应显示错误消息Minimum of 6 / Maximum of 16 characters。但它适用于输入少于6个字符但不适用于超过16个字符的值。看起来data-maxlength对表单验证没有影响。我的代码出了什么问题?



<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css">


<div class="form-group">
  <label for="user-username-input">User Name</label>
  <input type="text" class="form-control" id="user-username-input" placeholder="User Name" data-maxlength="16" data-minlength="6" data-error="Minimum of 6 / Maximum of 16 characters" required>
  <div class="help-block with-errors"></div>
</div>
&#13;
&#13;
&#13;

0 个答案:

没有答案