<input type="text" maxlength="11" /> 效果ok, 当 <input type="number" maxlength="11" />时maxlength失效,长度可以无限输入. 解放方案: <input type="number" oninput="if(value.length>11)value=value.slice(0,1…
<input type="text"  maxlength="5" />   效果ok, 当 <input type="number"  maxlength="5" />时maxlength失效,长度可以无限输入. 解放方案: <input type="number" oninput="if(value.length>5)value=value.slice(0,…
<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…
最近小颖在做公司的angular项目时,发现当input type="number"时,maxlength不起作用,百度了下解决方式,顺便记录下,以便后期查看嘻嘻 <input type="number" placeholder="1~99999999" oninput="if(value.length>8)value=value.slice(0,8)">…
<input type="number" oninput="if(value.length>11)value=value.slice(0,11)" />…
直接上答案 <style> input[type='number']{-moz-appearance:textfield;} input[type=number]::-webkit-inner-spin-button, input[type=number]::-webkit-outer-spin-button {-webkit-appearance: none;margin: 0;}</style>…
修改css /* 谷歌 */ input::-webkit-outer-spin-button, input::-webkit-inner-spin-button { -webkit-appearance: none; appearance: none; margin: 0; } /* 火狐 */ input{ -moz-appearance:textfield; } 这样就OK啦…
input 类型为number型时,maxlength不生效? 可以加oninput属性来控制最大长度:<input id="numInput" type="number" maxlength="3" value="" oninput="if(value.length>3)value=value.slice(0,3)">…
<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…
最近做项目用到input的size和maxlength属性,以前只顾用没有用心去看看这2个标签的区别,今天周末baidu了一下,有所理解.特记录于此!   <p>Name: <input type="text" name="fullname" maxlength="5" /></p>   <p>Name2: <input type="text" name="ful…