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> 元素的值发生改变时触发。

 

相关文章:

  • 2022-02-07
  • 2022-12-23
  • 2021-09-17
  • 2022-01-17
  • 2022-12-23
  • 2021-12-18
  • 2022-12-23
  • 2021-06-29
猜你喜欢
  • 2021-10-30
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-19
  • 2022-01-08
  • 2022-01-23
相关资源
相似解决方案