input的type设置为number的时候,maxlength无效

<input type="text" maxlength="6" /> 效果ok
 
<input type="number" maxlength="6" />
 
当input type = number 时maxlength失效,长度可以无限输入。
解放方案:
 
oninput事件 当长度超过截取
<input type="number" oninput="if(value.length>11)value=value.slice(0,11)

 

 
posted @ 2017-08-01 14:19  前进中的蜗牛  阅读(10139)  评论(0编辑  收藏  举报