<input type="number" maxlength="2" />
它可以在Firefox,IE等其他浏览器中使用,而不能在谷歌chrome中使用。有人可以建议如何解决chrome中的问题吗?
因为它是一个数字,所以您可以使用max,而不是maxlength。
您只需要输入两位数字,然后就可以使用以下代码
<input type="number" min="1" max="99" />
Use the max attribute for inputs of type="number". It will specify the highest possible number that you may insert
<input type="number" max="999" />
if you add both a max and a min value you can specify the range of allowed values:
<input type="number" min="1" max="999" />
For user experience, you would prefer the user not to be able to enter more than a certain number, use Javascript/jQuery.
EG: <input type="number" max="99" min="9" id="myInput"/>
$('#myinput').on('keydown', function () {
if($(this).val().length>2)
return false;
});
use max=""
and there is has to be a form
element for it to work otherwise it won't work.
尝试这个
<input type="tel" maxlength="2" />
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.