限定输入数字问题

wiseddl 2004-09-16 09:20:20
怎样在下面代吗中input中限定输入数字啊?不是高手不要答哦


<%
dim t1,t2,r1,result
if request("action")="chk" then
t1=cint(request("t1"))
t2=cint(request("t2"))
r1=request("r1")
if r1="V1" then
result=t1+t2
end if
if r1="V2" then
result=t1-t2
end if
if r1="V3" then
result=t1*t2
end if
if r1="V4" then
result=t1/t2
end if

response.write "结果为: "
response.write result
else
%>
<html>

<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 6.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>算术运算</title>
</head>

<body> 
<p>
<br><br>
</p>
<form method="GET" action="func.asp">
<table border="0" width="100%">
<tr>
<td width="7%"></td>
<td width="79%" align="center"><input type="text" name="T1" size="20"></td>
<td width="14%"></td>
</tr>
<tr>
<td width="7%"></td>
<td width="79%" align="center">
<table border="1" width="27%" cellspacing="0" cellpadding="0" style="border-collapse: collapse" bordercolor="#008080">
<tr>
<td width="53%" align="center"><input type="radio" value="V1" checked name="R1"></td>
<td width="147%" align="center">加</td>
</tr>
<tr>
<td width="53%" align="center"><input type="radio" value="V2" checked name="R1"></td>
<td width="147%" align="center">减</td>
</tr>
<tr>
<td width="53%" align="center"><input type="radio" value="V3" checked name="R1"></td>
<td width="147%" align="center">乘</td>
</tr>
<tr>
<td width="53%" align="center"><input type="radio" value="V4" checked name="R1"></td>
<td width="147%" align="center">除</td>
</tr>
</table>
</td>
<td width="14%"></td>
</tr>
<tr>
<td width="7%"></td>
<td width="79%" align="center"><input type="text" name="T2" size="20"></td>
<td width="14%"></td>
</tr>
<tr>
<td width="7%"></td>
<td width="79%" align="center"></td>
<td width="14%"></td>
</tr>
<tr>
<td width="7%"><INPUT TYPE="hidden" value="chk" name="action"></td>
<td width="79%" align="center"><input type="submit" value="提 交" name="B1">    
<input type="reset" value="重 写" name="B2"></td>
<td width="14%"></td>
</tr>
</table>
</form>
</body>

</html>
<%end if
%>
...全文
116 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
wiseddl 2004-09-23
  • 打赏
  • 举报
回复
我要的效果还没有达到啊
opolmzy 2004-09-22
  • 打赏
  • 举报
回复
没心思回答了,楼主,学习好~
zhejiang 2004-09-21
  • 打赏
  • 举报
回复
客户端用javascript来限制,另外服务端还要作一次验证,免得自己构造form递交非法查询。
wiseddl 2004-09-21
  • 打赏
  • 举报
回复
治标不治本啊
xing_shou 2004-09-17
  • 打赏
  • 举报
回复
那么复杂,用正则很简单的,/^(\d)+$/
fzxp 2004-09-16
  • 打赏
  • 举报
回复
he he .
你只要把输入框调整一下,不就OK了。
用不着那么麻烦吧。
izhouwei 2004-09-16
  • 打赏
  • 举报
回复
<input name="stu_num" type="text" size="12" onKeyUp="if(isNaN(this.value)){alert('您输入的不是学号,我们学校的学号是数字!');this.value='';}" maxlength="8" title="请添上您的学号">
tjficcbw 2004-09-16
  • 打赏
  • 举报
回复
行吗,斗你玩
再加上这个才行
function IsDigit()
{
return ((event.keyCode >= 48) && (event.keyCode <= 57));
}
tjficcbw 2004-09-16
  • 打赏
  • 举报
回复
我不是高手但我能回答
<input name="aa" type="text" id="aa" onKeyPress="event.returnValue=IsDigit();">
wiseddl 2004-09-16
  • 打赏
  • 举报
回复
具体点啊
  • 打赏
  • 举报
回复
t1=cint(request("t1"))
if not isNumeric(t1) then response.write("输入数字!!")

t2=cint(request("t2"))
if not isNumeric(t2) then response.write("输入数字!!")
guoweidong 2004-09-16
  • 打赏
  • 举报
回复
你的话说得过份了点吧.

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧