注册 登录
编程论坛 ASP技术论坛

各位大哥进来看看

静静听风 发布于 2008-01-11 16:07, 676 次点击
这是我自己写的一个VBS代码,是检查表单QQ的,我想让输入的字符必须为数字.
请各位大哥帮忙看下出错出在哪,谢谢了
<%
function  isNumber(String)
dim Letters,i,c
Letters  =  "1234567890"
for i=0 to len(String)
 c= mid(string,i,1)
if  instr(letters,c) < 1 then
isNumber=false
exit function
end if
next
isNumber=true
end function

' 调用函数
%>
<%
if not(isNumber(request.form("qq"))) then
response.write "<script language='javascript'>" & VbCRlf
        response.write "alert('QQ号必须为数字!');" & VbCrlf
        response.write "history.go(-1);" & vbCrlf
        response.write "</script>" & VbCRLF
        response.end
end if

%>
2 回复
#2
永夜的极光2008-01-11 16:51
判断数字有个现成的函数isnumeric(),返回true表示是数字
#3
天涯听雨2008-01-11 20:10
if Not isnumeric(qq) then
   response.write"<script language='javascript'>alert('QQ号必须为数字!');history.go(-1);</script>"
   response.end
end if
1