input只能輸入數字:
(只能輸入數字,並且輸入的值不能大於99),但是這樣有個問題,就是當輸入非數字字符時,輸入框中所有的字符都會被清除
<input type="text" id="feePercentage" name="feePercentage" value=""
onkeyup="if(isNaN(value) || value > 99)execCommand('undo')" onafterpaste="if(isNaN(value) || value > 99)execCommand('undo')" style="margin-left:0px; width:50px;" onchange="calc()"/>
解決方案:
(只清除非數字,原先的數字保留)
<input class="text" id="policyNo" name="policyNo" type="text" onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')"
maxlength="14" style="width:188px;" placeHolder="請輸入批單號">