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)">
posted @ 2017-01-06 16:28  SingleShadow  阅读(12523)  评论(0编辑  收藏  举报