有段表单验证总不对,姓名栏能正确验证,其它的不行
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<style type="text/css">
<!--表格定义样式,仅显示横边框 -->
body{
font-size:12px;
line-height:20px;
background:url();
}
table.tab{}
table.tab td{
height:30px;border-bottom:1px dashed #546F07;border-left:0px;border-right:0px;
}
<!--表格定义样式,全虚线边框 -->
.v tr{height:30px;}
.v {border-collapse: collapse}
.v td{border:1px dashed #6FB7E7;width:100;height:25; padding:0 5px;}
</style>
<script language="javascript">
function n()
{
if(document.myform.xm.value=="")
{
document.getElementById("divxm").innerHTML="登陆名不能为空";
document.myform.xm.focus();
return false
}
if(document.myform.xm.value.length<5)
{
document.getElementById("divxm").innerHTML="登陆名不少于5位";
document.myform.xm.focus();
return false
}
else
{
document.getElementById("divxm").innerHTML="<font color=#009900>√</font>";
}
if(document.myform.passswd.value=="")
{
document.getElementById("divpasswd").innerHTML="密码不能为空";
document.myform.passwd.focus();
return false;
}
if(document.myform.passwd.value.length<6)
{
document.getElementById("divpasswd").innerHTML="密码不少于6位";
document.myform.passwd.focus();
return false;
}
else
{
document.getElementById("divpasswd").innerHTML="<font color=#009900>√</font>";
}
if(document.myform.ver.value=="")
{
document.getElementById("divver").innerHTML="密码验证不能为空";
document.myform.ver.focus();
return false;
}
else
{
document.getElementById("divver").innerHTML="<font color=#009900>√</font>";
}
if(document.myform.ver.value!=document.myform.passwd.value)
{
document.getElementById("divver").innerHTML="密码验证码与密码不同";
document.myform.ver.focus();
return false;
}
else
{
document.getElementById("divver").innerHTML="<font color=#009900>√</font>";
}
if(document.myform.idnumber.value.length!=18)
{
document.getElementById("dividnumber").innerHTML="身份证号码不对";
document.myform.idnumber.focus();
return false;
}
else
{
document.getElementById("dividnumber").innerHTML="<font color=#009900>√</font>";
}
}
/*实现在页面加载时使用户名框获得焦点*/
window.onload = f;
function f(){document.getElementById("xm").focus();}
</script>
</head>
<body>
<table width="778" border="0" align="left" cellpadding="0" cellspacing="1" bgcolor="#0033CC" class="bt_link18">
<tr>
<td height="335" bgcolor="#FFFFFF">
<div style="width:777px; overflow:hidden; text-align:left;">
<form action="adduser1.asp?action=adduser" method="post" name="myform" id="myform" onsubmit="return check();">
<table width="100%" height="316" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#0000FF">
<tr bgcolor="#FFFFFF">
<td width="15%" height="23">用户名:</td>
<td width="49%"><h3>
<input name="xm" type="text" id="xm" size="20" maxlength="20">
</td>
<td width="36%"><div id="divxm"></div></td>
</tr>
<tr bgcolor="#FFFFFF">
<td height="25"><div align="right">密码:</div></td>
<td><input name="passwd" type="text" id="passwd" size="20" maxlength="20">
*</td>
<td><div id="divpasswd" style="color:#f00;"></div></td>
</tr>
<tr bgcolor="#FFFFFF">
<td height="23"><div align="right">确认密码:</div></td>
<td><input name="ver" type="text" id="ver" size="20" maxlength="20">
*</td>
<td><div id="divver" style="color:#f00;"></div></td>
</tr>
<tr bgcolor="#FFFFFF">
<td height="24"><div align="right">身份证号码:</div></td>
<td><input name="idnumber" type="text" id="idnumber" size="18" maxlength="18">
*</td>
<td><div id="dividnumber" style="color:#f00;"></div></td>
</tr>
<tr bgcolor="#FFFFFF">
<td> </td>
<td align="center"><input type="submit" name="xhd" value="提交" onClick="return n()">
<input type="reset" name="xhd2" value="重置"></td>
<td> </td>
</tr>
</table>
</form></div></td>
</tr>
</table>
</body>
</html>