<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)" />

很简单,搞定!

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-18
  • 2022-12-23
  • 2021-10-30
  • 1970-01-01
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-10-05
  • 2021-08-03
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案