input标签type为 number,属性maxlength无效

 

<input type="text" maxlength="5" />
maxlength效果ok,

当<input type="number" maxlength="5" />时maxlength失效,长度可以不受限输入。

解放方案:

<input type="number" oninput="if(value.length>5)value=value.slice(0,5)" />

转:https://www.cnblogs.com/yixiancheng/p/7268319.html

猜你喜欢

转载自blog.csdn.net/zhaofuqiangmycomm/article/details/88744075