今天在开发登录页时,需要设置登录输入框的长度,输入类型为number

<input type="number" maxlength="11" placeholder="请输入手机号">

  发现在这样写时,输入长度限制并没有生效,经过测试发现在type为number或者text时,设置maxlength参数并不会生效。

<input type="number" οninput="if(value.length > 11)value = value.slice(0, 11)" placeholder="请输入手机号">

  

转载于:https://www.cnblogs.com/sk-3/p/9047435.html

Logo

前往低代码交流专区

更多推荐