大家好,我在做一个注册页面的时候,发现验证函数不起做用,电击提交后直接到下一个页面,请问这是什么原因呢?
原文件如下:
<script language=vbscript>
<!--
sub tijiao_onclick()
if len(login.userid.value)<3 then
alert "用户名太短,请选择一个长度大于3的名字"
login.userid.select
exit sub
end if
if instr(trim(login.userrid.value)," ")>1 then
msgbox "用户名申请请不要加空格"
login.userid.select
exit sub
end if
if len(login.userpw.value)<4 then
alert "密码太短请选择一个长度大于4的密码"
login.userid.select
end if
if login.userpw.value<>login.verifypw.value then
alert "确认密码和密码不同,请确认"
login.userpw.value=""
login.verifypw.value=""
login.userpw.select
exit sub
end if
if login.name.value="" then
alert "为了更好的为您服务请输入您的名字"
login.name.select
exit sub
end if
if login.idnumber.value="" or not isnumeric(login.idnumber.value) or len(login.idnumber.value)<>15 and len(login.idnumber.value)<>18 then
alert "请正确输入您的身份证号码"
login.idnumber.select
exit sub
end if
if login.age.value="" or not isnumer(login.age.value) then
alert "请输入您的年龄"
login.age.select
exit sub
else
if cint(login.age.value)<12 then
alert "年龄输入范围错误"
login.age.select
exit sub
end if
if login.address.value="" then
alert "请输入您的详细联系地址"
login.address.select
exit sub
end if
if len(login.zipcode.value)<>6 or not isnumeric(login.zipcode.value) then
alert "邮政编码输入有误,请更正"
login.zipcode.value.select
exit sub
end if
if not login.phone.value="" then
if isnumeric(login.phone.value) then
if len(login.phone.value)<7 or left(login.phone.value,1)="-" or left(login.phone.value,1)="+" then
alert "电话号码输入有误"
login.phone.select
exit sub
end if
else
pos=instr(login.phone.value,"-")
len_phone=len(login.phone.value)
if pos>1 and pos<len_phone then
lef=left(login.phone.value,pos-1)
rig=right(login.phone.value,len_phone-pos)
if not isnumeric(lef) or not isnumeric(rig) or len(rig)<5 then
alert "电话号码号码输入有误"
login.phone.select
exit sub
end if
else
alert "电话号码输入有误"
login.phone.select
end if
end if
end if
if login.email.value="" then
alert "为了与您联系方便,请输入E-mail地址"
login.email.select
exit sub
else
if not right(login.email.value,4)".com" and not right(login.email.value,4)=".net" and not
right(login.email.value,3)=".cn" or instr(login.email.value,"@.") then
alert "请正确输入您的email"
login.email.select
exit sub
end if
login.submit
end sub
-->
</script>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>注册新会</title>
</head>
<body>
<form method="post"action="custadd.asp" name="login" >
<p>会 员 名:
<input name="userid" type="text" maxlength="8">
*用户名长度为3-8位
</p>
<p>密 码 :
<input name="userpw" type="password" maxlength="8">
*密码长度为4-8位</p>
<p>密码确认:
<input name="verifypw" type="password" id="verifypw" maxlength="8">
*</p>
<p>您的姓名:
<input name="name" type="text" id="name" maxlength="8">
*</p>
<p>身份证号:
<input name="idnumber" type="text" maxlength="18">
*</p>
<p>性 别:
<input type="radio" name="sex" value="男"checked>男
<input type="radio" name="sex" value="女">女</p>
<p> 您的年龄:
<input name="age" type="text" size="2" maxlength="2">
*</p>
<p>详细地址:
<input name="address" type="text"size="20" maxlength="20">
*</p>
<p>邮政编码:
<input name="zipcode" type="text" size="20" maxlength="6">
*</p>
<p>电话号码:
<input name="phone" type="text" size="20">
</p>
<p>电子邮箱:
<input name="email" type="text" size="20" maxlength="30">
*</p>
<p> <div align="center"> <input name="tijiao" type="submit" value="提交">
<input name="zhongzhi" type="reset" id="zhongzhi2" value="重置"></div>
</p>
</form>
</body>
</html>