input只能輸入數字並限制長度

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)">
發佈了44 篇原創文章 · 獲贊 11 · 訪問量 49萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章