<script language="javascript" type="text/javascript">
function judge()
{
if (document.form1.userpwd1.value=="")
{alert("请输入你的密码");
document.form1.userpwd1.focus()
document.form1.userpwd1.select()
return false;}
if (document.form1.userpwd2.value!=document.form1.userpwd1.value)
{alert("两次输入密码不一致,请重新输入");
document.form1.userpwd1.focus()
document.form1.userpwd1.select()
return false;}
if (document.form1.userpwd1.value.length<4||document.form1.userpwd1.value.length>8)
{alert("请输入4-8位的密码");
document.form1.userpwd1.focus()
document.form1.userpwd1.select()
return false;}
if (document.form1.nickname.value=="")
{alert("请输入你的昵称");
document.form1.nickname.focus()
document.form1.nickname.select()
return false;}
var regx=/^\d{2,2}$/;
if(!regx.test(document.form1.age.value))
{alert("请输入你正确的年龄");
document.form1.age.focus()
document.form1.age.select()
return false;}
var regx=/^\d{5,9}$/;
if(!regx.test(document.form1.qq.value))
{alert("请输入你正确的QQ号");
document.form1.qq.focus()
document.form1.qq.select()
return false;}
/*下面为只判断位数
if (document.form1.qq.value.length<5||document.form1.qq.value.length>9 )
{alert("请输入你正确的QQ号");
document.form1.qq.focus()
document.form1.qq.select()*/
var mailstr;
mailstr=document.form1.mail.value;
if (mailstr.indexOf("@")==-1 || mailstr="")
{alert("请输入你正确的E-mail地址");
document.form1.mail.focus()
document.form1.mail.select()
return false;}
}
</script>
上面为客户端的验证程序!
下面是表单代码 在提交的时候执行 judge()
<form id="form1" name="form1" method="post" action="xgzl_cl.asp" onsubmit="return judge()"/>
<input name="textfield" type="text" class="heng" value="<% =request.Cookies("userid")%>" readonly="readonly"/>
<input name="textfield2" type="text" class="heng" value="<% =server.htmlencode (userpwd1)%>" readonly="readonly"/>
<input name="userpwd1" type="text" class="heng" />
<input name="userpwd2" type="text" class="heng" />
<input name="nickname" type="text" class="heng" value="<% =server.htmlencode (nickname)%>" />
<input type="radio" name="sex" checked="checked" value="1"/>
<span class="pt10">男
<input type="radio" name="sex" value="0"/>
女</span></div>
<input name="age" type="text" class="heng" value="<% =server.htmlencode (age)%>" />
<input name="qq" type="text" class="heng" value="<% =server.htmlencode (qq)%>"/>
<input name="address" type="text" class="heng" value="<% =server.htmlencode (address)%>"/>
<input name="mail" type="text" class="heng" value="<% =server.htmlencode (mail)%>"/>
<input name="Submit" type="submit" class="loginbutton" value="提交" /></form>
这以前我用过了,能用,可现在却不行了!
保存为xgzl.asp 可现在不通过验证直接都提交到了处理的页面,郁闷的很!
大侠们看看那错了!