日期:2014-05-16  浏览次数:20378 次

通过Javascript控制文本框中只输入数字
	   function goto_page(e){
	       var keynumber; //键盘ASCII码
	       if(window.event){
	           //浏览器为IE
	           keynumber = e.keyCode;
	       }
	       if(e.which){
	           //浏览器为Firefox、Opera
	           keynumber = e.which;
	       }
	       if(keynumber < 48 || keynumber > 105 || (keynumber > 57 && keynumber < 96)){
	           document.getElementById("pageno").value="1";
	       }
	   }


<input type="text" id="pageno" onkeydown="goto_page(e)" onkeyup="goto_page(e)"></input>