maxlength 屬性規定輸入字段的最大長度,以字符個數計。
maxlength 屬性與 <input type="text"> 或 <input type="password"> 配合使用。
maxlength 屬性 用在<input type="number"> 是沒效果的
解放方案:
<input type="number" oninput="if(value.length>5)value=value.slice(0,5)" />
oninput 事件在用戶輸入時觸發。
該事件在 <input> 或 <textarea> 元素的值發生改變時觸發。