BootStrap中对input的type自带的验证种类
生活随笔
收集整理的這篇文章主要介紹了
BootStrap中对input的type自带的验证种类
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
場景
Bootstrap 提供了對所有原生的 HTML5 的 input 類型的支持,包括:
text、password、datetime、datetime-local、date、month、time、week、number、email、url、search、tel 和 color。
適當(dāng)?shù)?type 聲明是必需的,這樣才能讓 input 獲得完整的樣式。
舉例
添加對輸入內(nèi)容是否為數(shù)字的驗(yàn)證
只需要將type改為number,則只能輸入數(shù)字
<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>效果
總結(jié)
以上是生活随笔為你收集整理的BootStrap中对input的type自带的验证种类的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: SSM中使用Druid连接池
- 下一篇: Input中实现对身份证的验证