回 帖 发 新 帖 刷新版面

主题:JAVA验证表单的问题,请高手帮忙看看

<!--#include file="conn.asp"-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title></title>
<link href="css.css" rel="stylesheet" type="text/css">
<script language=JavaScript>
function IsDigit()
{
  return ((event.keyCode >= 48) && (event.keyCode <= 57));
}
</script>
<SCRIPT LANGUAGE=JavaScript>
<!--
function checkuserinfo()
{
   if(checkspace(document.userinfo.userName.value)) {
    document.userinfo.userName.focus();
    alert("对不起,请填写登陆名!");
    return false;
  }
    if(checkspace(document.userinfo.passwd.value) || document.userinfo.passwd.value.length < 6 || document.userinfo.passwd.value.length >20) {
    document.userinfo.passwd.focus();
    alert("密码长度不能不能这空,在6位到20位之间,请重新输入!");
    return false;
  }
    if(document.userinfo.passwd.value != document.userinfo.passwd1.value) {
    document.userinfo.passwd.focus();
    document.userinfo.passwd.value = '';
    document.userinfo.passwd1.value = '';
    alert("两次输入的密码不同,请重新输入!");
    return false;
  }
  if(checkspace(document.userinfo.buyerpeople.value)) {
    document.userinfo.buyerpeople.focus();
    alert("对不起,请填写联系电话!");
    return false;
  } 
 if(document.userinfo.buyermail.value.length!=0)
  {
    if (document.userinfo.buyermail.value.charAt(0)=="." ||        
         document.userinfo.buyermail.value.charAt(0)=="@"||       
         document.userinfo.buyermail.value.indexOf('@', 0) == -1 || 
         document.userinfo.buyermail.value.indexOf('.', 0) == -1 || 
         document.userinfo.buyermail.value.lastIndexOf("@")==document.userinfo.buyermail.value.length-1 || 
         document.userinfo.buyermail.value.lastIndexOf(".")==document.userinfo.buyermail.value.length-1)
     {
      alert("Email地址格式不正确!");
      document.userinfo.buyermail.focus();
      return false;
      }
   }
 else
  {
   alert("Email不能为空!");
   document.userinfo.buyermail.focus();
   return false;
   }
   if(checkspace(document.userinfo.otherlx.value)) {
    document.userinfo.otherlx.focus();
    alert("对不起,请留下您的其他联系方式!");
    return false;
  }
}
function checkspace(checkstr) {
  var str = '';
  for(i = 0; i < checkstr.length; i++) {
    str = str + ' ';
  }
  return (str == checkstr);
}
//-->
</script>
</head>

<body>

<table width="760" height="3" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td></td>
  </tr>
</table>
<table width="760" height="25" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="337">你现在的位置:<a href="index.asp">首页 &gt; 会员注册 </a></td>
</div>
  </tr>
</table>
<table width="760" height="5" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td></td>
  </tr>
</table>
<table width="760" height="280" border="0" align="center" cellpadding="15" cellspacing="1" bgcolor="#BAC5D9">
  <tr>
    <td align="center" valign="top" bgcolor="#FFFFFF"><table width="100%"  border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td align="center" bgcolor="#E7E7F4"><table width="95%" height="25"  border="0" cellpadding="10" cellspacing="1" class="bian1">
              <tr>
                <td align="center" class="biaotia">会员注册</td>
              </tr>
          </table></td>
        </tr>
      </table>
      <table width="100%"  border="0" cellspacing="0" cellpadding="10">
        <tr>
          <td align="center" bgcolor="#E7E7F4">
          <form action="regadd.asp" method="post" name=userinfo id="form1">
          <table width="90%" border="0" cellpadding="6" cellspacing="1" bgcolor="#FFFFFF">

            <tr bgcolor="#E7E7F4">
              <td width="29%"><div align="right">登陆名:</div></td>
              <td width="29%"><input name="userName" type="text" class="ziti1" id="userName" size="25" maxlength="12"></td>
              <td width="42%">会员登陆用的名字</td>
            </tr>
            <tr bgcolor="#E7E7F4">
              <td height="14"><div align="right">登陆密码:</div></td>
              <td><input name="passwd" type="password" class="ziti1" id="passwd" size="27"></td>
              <td>长度必须大于6个字符小于50个字符,只能为英语字、数字</td>
            </tr>
            <tr bgcolor="#E7E7F4">
              <td><div align="right">确认密码:</div></td>
              <td><input name="passwd1" type="password" class="ziti1" id="passwd1" size="27"></td>
              <td>请将输入的密码再次输入,以免设置密码出错。</td>
            </tr>
            <tr bgcolor="#E7E7F4">
              <td><div align="right">联系电话:</div></td>
              <td><input name="buyerpeople" type="text" class="ziti1" id="buyerpeople" size="25"></td>
              <td>方便我们联系你。</td>
            </tr>
            <tr bgcolor="#E7E7F4">
              <td><div align="right">E_Mail:</div></td>
              <td><input name="buyermail" type="text" class="ziti1" id="buyermail" size="25"></td>
              <td>以便于我们为您提供有效的服务。</td>
            </tr>
            <tr bgcolor="#E7E7F4">
              <td colspan="3"><div align="center">
               <input onClick="return checkuserinfo()" type="submit" name="Submit" value="提交">
              </div></td>
              </tr>
          </table>
          </form>
          </td>
        </tr>
      </table></td>
  </tr>
</table>
<table width="760" height="5" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td></td>
  </tr>
</table>
<table width="760" height="5" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td></td>
  </tr>
</table>
</body>
</html>
点击提交后就好象跳过验证就直接提交了 请高手帮忙看看

回复列表 (共1个回复)

沙发

我试的可以呀
你不输入用户名或密码试试

我来回复

您尚未登录,请登录后再回复。点此登录或注册