使用input数字number类型的时候maxlength无效,假设须要控制输入数量为18,能够用如下方式:spa
无效:input
<input type="text" maxlength="18" /> 效果ok,当 <input type="number" maxlength="18" />class
有效:数字
<input type="number" oninput="if(value.length>18)value=value.slice(0,18)" /> tag