function checkNumber()
{
if(!(((window.event.keyCode>=48)&&(window.event.keyCode<=57))||(window.event.keyCode==13)||(window.event.keyCode==46)||(window.event.keyCode==45)))
{
window.event.keyCode=0;
alert("对不起,只能输入数字。");
}
}
文本框加上如下事件 onKeyPress='checkNumber()'