input 属性为 number,maxlength不起作用如何解决?

<input type="text"  maxlength="10" />   效果ok,当 <input type="number"  maxlength="10" />时maxlength失效,长度可以无限输入。

解放方案:

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

很简单,搞定!

原文:https://blog.csdn.net/malan_wpf/article/details/50788275

原文地址:https://www.cnblogs.com/luoshengjie/p/10243558.html