0
点赞
收藏
分享

微信扫一扫

BootStrap中对input的type自带的验证种类


场景

Bootstrap 提供了对所有原生的 HTML5 的 input 类型的支持,包括:

text、password、datetime、datetime-local、date、month、time、week、number、email、url、search、tel 和 color。

适当的 type 声明是必需的,这样才能让 input 获得完整的样式。

举例

添加对输入内容是否为数字的验证

只需要将type改为number,则只能输入数字

<form action="addUser">
<div class="form-group">
<label for="name">用户名</label>
<input type="text" class="form-control" id="name" name ="name" placeholder="name">
</div>
<div class="form-group">
<label for="age">年龄</label>
<input type="number" class="form-control" id="age" name="age" placeholder="age">
</div>
<button type="submit" class="btn btn-default">新增用户</button>
</form>

效果

BootStrap中对input的type自带的验证种类_HTML5

举报

相关推荐

0 条评论