1. 程式人生 > >文字框中onkeypress在火狐無法輸入的bug

文字框中onkeypress在火狐無法輸入的bug

-------文字框呼叫

onkeypress="return inputNum(event);"

----js

<script type="text/javascript">
function inputNum(evt){  
    //火狐使用evt.which獲取鍵盤按鍵值,IE使用window.event.keyCode獲取鍵盤按鍵值
    var ev = evt.which?evt.which:window.event.keyCode;
    if(ev>=48&&ev<=57){
        return true;    
    }else{
        return false;
    }  

</script>