input只能输入数字并限制长度
<style>
/*在chrome下移除input[number]的上下箭头*/
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button{
-webkit-appearance: none !important;
margin: 0;
}
/*在firefox下移除input[number]的上下箭头*/
input[type="number"]{-moz-appearance:textfield;}
<style>
<input type="number" oninput="if(value.length>5)value=value.slice(0,5)">
本文介绍了一种使用HTML和CSS的方法来限制input[type=number]的输入仅为数字,并且设置了最大输入长度为5位数。此外,还展示了如何通过内联样式移除Chrome和Firefox浏览器中数字输入框的增减按钮。
1968

被折叠的 条评论
为什么被折叠?



