标题:有段表单验证总不对,姓名栏能正确验证,其它的不行
只看楼主
xhdxhd123
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2012-1-11
结帖率:50%
已结贴  问题点数:20 回复次数:1 
有段表单验证总不对,姓名栏能正确验证,其它的不行
<!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>&nbsp;</td>
          <td align="center"><input type="submit" name="xhd" value="提交" onClick="return n()">
            <input type="reset" name="xhd2" value="重置"></td>
          <td>&nbsp;</td>
        </tr>
      </table>
    </form></div></td>
  </tr>
</table>
</body>
</html>
搜索更多相关主题的帖子: 表格 background PUBLIC title 
2012-02-14 10:58
ysf0181
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:55
帖 子:914
专家分:2385
注 册:2006-10-4
得分:20 
<!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()
{
  var ii = 0 ;
  if(document.myform.xm.value==""){
    document.getElementById("divxm").innerHTML="登陆名不能为空";
    document.myform.xm.focus();
    ii = parseInt(ii)+ + 1
//return false
  }
  if(document.myform.xm.value.length<5){
      document.getElementById("divxm").innerHTML="登陆名不少于5位";
      document.myform.xm.focus();
      ii = parseInt(ii)+ + 1
//return false
  }
  else{
    document.getElementById("divxm").innerHTML="<font color=#009900>√</font>";
  }
  
  if(document.myform.passwd.value=="")
  {
    document.getElementById("divpasswd").innerHTML="密码不能为空";
    document.myform.passwd.focus();
    ii = parseInt(ii)+ + 1
//return false;
   }
   //alert(ii)
 // return false;
if(document.myform.passwd.value.length<6)
{
document.getElementById("divpasswd").innerHTML="密码不少于6位";
document.myform.passwd.focus();
   ii = parseInt(ii)+ + 1
//return false;
}
else
{
document.getElementById("divpasswd").innerHTML="<font color=#009900>√</font>";
}
if(document.myform.ver.value=="")
{
document.getElementById("divver").innerHTML="密码验证不能为空";
document.myform.ver.focus();
  ii = parseInt(ii)+ + 1
//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();
  ii = parseInt(ii)+ + 1
//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();
  ii = parseInt(ii)+ + 1
//return false;
}
else
{
document.getElementById("dividnumber").innerHTML="<font color=#009900>√</font>";
}

if(ii > 0){
  return false;
}


}


/*实现在页面加载时使用户名框获得焦点*/
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>&nbsp;</td>
          <td align="center"><input type="submit" name="xhd" value="提交" onClick="return n()">
            <input type="reset" name="xhd2" value="重置"></td>
          <td>&nbsp;</td>
        </tr>
      </table>
    </form></div></td>
  </tr>
</table>
</body>
</html>

ASP讨论QQ群:251346273
2012-02-14 11:29



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-360869-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.990723 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved