2014-10-28 38 views
0

嗨,我有一個數字輸入。 因此它在探險家中效果不錯,因爲它沒有箭頭。 和鉻和更新的瀏覽器它沒有照顧最大長度。檢查數字交換javascript數字

<input type="text" id="amount2" name="quantity2" class="amountBox" value="0" onchange="ChangeSecondAmount(this.value)" maxlength="4" onkeypress="return /\d/.test(String.fromCharCode(((event||window.event).which||(event||window.event).which)));"/> 

也許我可以改變onkeypress函數來檢查數字的數量?

非常感謝。

回答

0

使用'max'屬性來指定長度。

+0

但它沒有幫助,因爲我想讓用戶改變那個盒子 – Ruthie 2014-10-28 17:31:29