你要写关于验证的程序我建议你要么就写JAVASCRIPT函数function
或者是直接用VBscript写,我给你一个你试试!
这是一个用户注册的代码:
<!--#include file="conn.asp"-->
<% if request.Form("user")="" then
response.Write"<script language=javascript>alert('请输入用户名');history.back(-1);</script>"
response.End()
end if
if request.Form("pwd")="" then
response.Write"<script language=javascript>alert('请输入密码');history.back(-1);</script>"
response.End()
end if
if request.Form("pwd2")="" then
response.Write"<script language=javascript>alert('请再次输入密码');history.back(-1);</script>"
response.End()
end if
pwd=trim(request.Form("pwd"))
pwd2=trim(request.Form("pwd2"))
if not pwd=pwd2 then
response.Write"<script language=javascript>alert('两次密码输入不一致!请重新输入!');history.back(-1);</script>"
response.End()
end if
if request.Form("email")="" then
response.Write"<script language=javascript>alert('请输入邮箱');history.back(-1);</script>"
response.End()
end if
For I=1 to Len(request.Form("email"))
If Mid(request.Form("email"),i,1)="@" Then
Flag=1
End If
next
if Flag<>1 then
response.Write"<script language=javascript>alert('请输入合法的邮箱地址!');history.back(-1);</script>"
end if
if request.Form("question")="" then
response.Write"<script language=javascript>alert('请输入密码提示问题!');history.back(-1);</script>"
response.End()
end if
if request.Form("answer")="" then
response.Write"<script language=javascript>alert('请输入密码提示答案!');history.back(-1);</script>"
response.End()
end if
user=request.Form("user")
pwd=request.Form("pwd")
sex=request.Form("sex")
qq=request.Form("QQ")
email=request.Form("email")
underwrite=request.Form("underwrite")
question=request.Form("question")
answer=request.Form("answer")
image=request.Form("ihead")
set rs=server.createobject("adodb.recordset")
set rs1=server.createobject("adodb.recordset")
sql="select * from login where user='"&user&"'"
rs.open sql,conn,1,3
if rs.EOF or rs.BOF then
rs1.open"login",conn,1,3
rs1.addnew array("user","pwd","sex","QQ","email","underwrite","question","answer","image"),_
array(user,pwd,sex,QQ,email,underwrite,question,answer,image)
%>
<script language="vbscript">
window.location.href="login_2.asp"
</script>
<%
rs1.close
set rs1=nothing
%>
<%
else
%>
<script language="vbscript">
alert("对不起!此用户已存在!")
history.back
</script>
<%
end if
rs.Close
set rs=nothing
%>