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

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

解放方案:

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

原文地址:https://www.cnblogs.com/llynic/p/6856508.html