请帮忙帮到底
说的详细一点点,谢谢?
[CODE]<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!-- #include file="conn.asp" -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>:::判断输入框是否为数字:::</title>
</head>
<body bgcolor="#6699cc" onload="setup()" >
<form name="input_form" action="add_panduan.asp" method="post" onSubmit="return checkform();">
<input name="panduan" type="text" class="inputform1" id="panduan" onMouseOver="this.focus();" size="10">
<input type=submit value=完成录入 name=Submit>
<input type=reset value=清空重写 name=Submit_a>
</form>
<script language="JavaScript" >
function checkform()
{
var subst = document.input_form;
if (subst.panduan.value=="")
{
alert("对不起!判断内容不能为空哦!");
subst.panduan.focus();
return false;
}
if (subst.panduan.value!="")
{
if(onlyNum(subst.panduan.value)==0)
{
alert("对不起!判断内容只能输入数字!");
subst.panduan.focus();
return false;
}
}
return true;
}
function onlyNum(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>
</html>[/CODE]
[CODE]<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!-- #include file="conn.asp" -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>:::判断输入框是否为数字:::</title>
</head>
<body bgcolor="#6699cc" onload="setup()" >
<form name="input_form" action="add_panduan.asp" method="post" onSubmit="return checkform();">
<input name="panduan" type="text" class="inputform1" id="panduan" onMouseOver="this.focus();" size="10">
<input type=submit value=完成录入 name=Submit>
<input type=reset value=清空重写 name=Submit_a>
</form>
<script language="JavaScript" >
function checkform()
{
var subst = document.input_form;
if (subst.panduan.value=="")
{
alert("对不起!判断内容不能为空哦!");
subst.panduan.focus();
return false;
}
if (subst.panduan.value!="")
{
if(onlyNum(subst.panduan.value)==0)
{
alert("对不起!判断内容只能输入数字!");
subst.panduan.focus();
return false;
}
}
return true;
}
function onlyNum(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>
</html>[/CODE]
[CODE]<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!-- #include file="conn.asp" -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>:::判断输入框是否为数字:::</title>
</head>
<body bgcolor="#6699cc" onload="setup()" >
<form name="input_form" action="add_panduan.asp" method="post" onSubmit="return checkform();">
<input name="panduan" type="text" class="inputform1" id="panduan" onMouseOver="this.focus();" size="10">
<input type=submit value=完成录入 name=Submit>
<input type=reset value=清空重写 name=Submit_a>
</form>
<script language="JavaScript" >
function checkform()
{
var subst = document.input_form;
if (subst.panduan.value=="")
{
alert("对不起!判断内容不能为空哦!");
subst.panduan.focus();
return false;
}
if (subst.panduan.value!="")
{
if(onlyNum(subst.panduan.value)==0)
{
alert("对不起!判断内容只能输入数字!");
subst.panduan.focus();
return false;
}
}
return true;
}
function onlyNum(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>
</html>[/CODE]
[CODE]<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!-- #include file="conn.asp" -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>:::判断输入框是否为数字:::</title>
</head>
<body bgcolor="#6699cc" onload="setup()" >
<form name="input_form" action="add_panduan.asp" method="post" onSubmit="return checkform();">
<input name="panduan" type="text" class="inputform1" id="panduan" onMouseOver="this.focus();" size="10">
<input type=submit value=完成录入 name=Submit>
<input type=reset value=清空重写 name=Submit_a>
</form>
<script language="JavaScript" >
function checkform()
{
var subst = document.input_form;
if (subst.panduan.value=="")
{
alert("对不起!判断内容不能为空哦!");
subst.panduan.focus();
return false;
}
if (subst.panduan.value!="")
{
if(onlyNum(subst.panduan.value)==0)
{
alert("对不起!判断内容只能输入数字!");
subst.panduan.focus();
return false;
}
}
return true;
}
function onlyNum(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>
</html>[/CODE]
function isNumber(pObj,errMsg){
var obj = eval(pObj);
strRef = "1234567890";
if(!isEmpty(pObj,errMsg))return false;
for (i=0;i<obj.value.length;i++) {
tempChar= obj.value.substring(i,i+1);
if (strRef.indexOf(tempChar,0)==-1) {
if (errMsg == null || errMsg =="")
alert("数据不符合要求,请检查");
else
alert(errMsg);
if(obj.type=="text")
obj.focus();
return false;
}
}
return true;
}
判断是否是数字,数字可以为负数
function isNegative(pObj,errMsg){
var obj = eval(pObj);
strRef = "1234567890-";
if(!isEmpty(pObj,errMsg))return false;
for (i=0;i<obj.value.length;i++) {
tempChar= obj.value.substring(i,i+1);
if (strRef.indexOf(tempChar,0)==-1) {
if (errMsg == null || errMsg =="")
alert("数据不符合要求,请检查");
else
alert(errMsg);
if(obj.type=="text")
obj.focus();
return false;
}else{
if(i>0){
if(obj.value.substring(i,i+1)=="-"){
if (errMsg == null || errMsg =="")
alert("数据不符合要求,请检查");
else
alert(errMsg);
if(obj.type=="text")
obj.focus();
return false;
}
}
}
}
return true;
}