假如您的文本框的名称是:shuzi
=======================================================
//文本框的名称是:shuzi;
[CODE] <form name="input_form" action="name.asp" method="post" onSubmit="return checkform();">
<input name="shuzi" type="text" onMouseOver="this.focus();" size="15">
<input type=submit value=确定 name=Submit>
</form>
<script language="JavaScript" >
function checkform()
{
var subst = document.input_form;
if(onlyNum_Point(subst.shuzi.value)==0)
{
alert("对不起!本框只能输入数字!");
subst.shuzi.focus();
return false;
}
return true;
}
function onlyNum_Point(NUM)
{
var i,j,strTemp;
strTemp="0123456789.";
if ( NUM.length== 0)
return 0
for (i=0;i<NUM.length;i++)
{
j=strTemp.indexOf(NUM.charAt(i));
if (j==-1)
{
//说明有字符不是数字
return 0;
}
}
//说明是数字
return 1;
}
</script>[/CODE]
=============================================================
不晓得是不是您想要的答案!
[此贴子已经被作者于2006-6-20 8:21:48编辑过]