<div class="codetitle"> <span><a style="CURSOR: pointer" data="13467" class="copybut" id="copybut13467" onclick="doCopy('code13467')"><u>複製程式碼</u></a></span> 程式碼如下:</div> <div class="codebody" id="code13467"> <br><script language="javascript" type="text/javascript"> <BR>function check(event){ <BR>//使用者每按下一個鍵,就去判斷是不是一個數<BR>if(event.keyCode<48 || event.keyCode>57){ <BR> window.alert("你輸入的不是數字!"); <BR>return false; <BR>} <BR>} <BR></script> <br> <br><input type="text " onkeypress="return check(event)"> <br> <br> </div>