function checkKeyPressNumAndPercent()
{
try{
if ((window.event.keyCode<48 && window.event.keyCode!=46) || window.event.keyCode>58)
{
window.event.keyCode=0;
return false;
}
}catch(e){alert(e.description);}
}
{
try{
if ((window.event.keyCode<48 && window.event.keyCode!=46) || window.event.keyCode>58)
{
window.event.keyCode=0;
return false;
}
}catch(e){alert(e.description);}
}
<input name=a onkeypress="checkKeyPressNumAndPercent()" onblur="checkNum(this)">
<SCRIPT LANGUAGE="JavaScript">
<!--
function checkNum(thisObj)
{
if(isNaN(thisObj.value)){
alert("只允许输入数字!");
thisObj.value=0;
}
}function checkKeyPressNumAndPercent()
{
try{
if ((window.event.keyCode<48 && window.event.keyCode!=46) || window.event.keyCode>58)
{
window.event.keyCode=0;
return false;
}
}catch(e){alert(e.description);}
}
//-->
</SCRIPT>