asp数据校验

<%

if trim(request("action"))="add" then

if request.form("cn_name1")=Empty or request.Form("pwd")=Empty or request.Form("pwd2")=Empty or request.Form("class")=Empty   then

response.Write("<script language=javascript>" & chr(13) & "alert('错误:请将信息输入完整!带*项必须填写!');" & "javascript:history.go(-1)" & "</script>")

elseif request.form("pwd") <> request.form("pwd2") then

response.write("<script language='javascript'> alert('错误:密码与确认密码不符!'); javascript:history.go(-1) </script>")

elseif len(request.form("cn_name1"))>16 then

response.write("<script language='javascript'> alert('错误:用户名长度超过16个字符,10个汉字'); javascript:history.go(-1) </script>")

elseif len(request.form("cn_name1"))<4 then

response.write("<script language='javascript'> alert('错误:用户名长度少于4个字符,2个汉字'); javascript:history.go(-1) </script>")

elseif len(request.form("class"))<2 then

response.write("<script language='javascript'> alert('错误:班级名称少于4个字符!'); javascript:history.go(-1) </script>")

elseif len(request.form("pwd"))>20 or len(request.form("pwd"))<6 then

response.write("<script language='javascript'> alert('错误:你输入的密码长度不符合!'); javascript:history.go(-1) </script>")

end if

end if

%>

原文地址:https://www.cnblogs.com/ince/p/9154754.html