相关文章推荐
安静的春卷  ·  WindowManager.LayoutPa ...·  昨天    · 
行走的眼镜  ·  cout 输出 uint8_t ...·  9 月前    · 
刚毅的花卷  ·  ORA-01422: ...·  1 年前    · 
朝气蓬勃的伤疤  ·  Oops!!! - 简书·  1 年前    · 
力能扛鼎的咖啡  ·  Lua 5.3 参考手册·  1 年前    · 

<input type="text"  maxlength="5" />   效果ok,当 <input type="number"  maxlength="5" />时maxlength失效,长度可以无限输入。

解放方案:

<input type="number" οninput="if(value.length>5)value=value.slice(0,5)" />

使用 html代码解决 < input type=" number " maxlength ="5" on input ="if(value.length>5)value=value.slice(0,5)" /> 使用 js代码解决 //输入框为数字类型时防止 maxlength 属性不起作用 $(' input ').bind(' input propertychange', function() {...
v-model="formAdd.xxx" on input ="if(value.length > 3) value=value.slice(0, 3)" onkeypress="return (/[\d]/.test(String.fromCharCode(event.keyCode)));" type=" number " placeho.