<html>
<head>
<title>综合查询</title>
<script language="JavaScript">
   function verfy()
   {
     if ((document.form.id.value == "") && (document.form.name.value == "") && document.form.address.value == "") 
      {
    alert("请您至少填写身份证号、姓名、暂住地址中的一项!");
    document.form.id.focus();
    return (false);
      }
     if (document.form.checkbox1.value!= "")
      {
           if ((document.form.id.value == "") || (document.form.id.value.length !=18 && document.form.id.value.length !=10))
           {
       alert("请您填写正确的身份证号!");
       document.form.id.focus();
       return (false);
           }
      }
 if (document.form.checkbox4.value!= "")
  {
           if ((document.form .csnf .value == "" )||(document.form .csnf .value  <= 1900 && document.form.csnf.value != ""))
               {
               alert("请填写正确年份");
               document.form.csnf.focus();
               return (false);
               }
           if (isNaN(document.form .csyf .value )||(document.form.csyf.value != "" && document.form.csyf.value < 1 || document.form.csyf.value > 12))
               {
               alert("请填写正确的月份");
               document.form.csyf.focus();
               return (false);
               }
           if (isNaN(document.form .csri .value )||(document.form.csri.value != "" && document.form.csri.value < 1 || document.form.csri.value > 31))
               {
               alert("请填写正确的日期");
               document.form.csri.focus();
               return (false);
               }     
           if (!((document.form.csri .value =="" && document.form.csyf.value =="" && document.form .csnf .value =="")||(document.form.csri .value!="" && document.form.csyf.value!="" && document.form .csnf .value !="")))
               {
               alert("请填写完整有效时间");
               document.form.csnf.focus ();
               return (false);
               }
      } 
   }
</script>
</head><body>
<p>&nbsp; </p>
<form name="form" action="zhshow.asp" method="post"  onsubmit="return verfy()">
  <table width="97%" border="0" align="center">
    <tr> 
      <td colspan="3">请在您所知的查询条件左边打勾,并在右边添入相应信息!</td>
    </tr>
    <tr> 
      <td width="19%">&nbsp;</td>
      <td colspan="2">*注意:需输入身份证号、姓 名、住 址中至少一个</td>
    </tr>
    <tr> 
      <td><input type="checkbox" name="checkbox1" value="id_no">
        身份证号:</td>
      <td colspan="2"><input name="id" type="text" id="id"></td>
    </tr>
    <tr> 
      <td><input type="checkbox" name="checkbox2" value="name">
        姓 名 :</td>
      <td colspan="2"><input name="name" type="text" id="name3"></td>
    </tr>
    <tr> 
      <td height="20"><input type="checkbox" name="checkbox3" value="sex_no">
        性 别 :</td>
      <td colspan="2"> <select name="sex">
          <option value="男">男</option>
          <option value="女">女</option>
        </select> </td>
    </tr>
    <tr> 
      <td><input type="checkbox" name="checkbox4" value="birthday">
        出生日期:</td>
      <td colspan="2"> 
        <input name="csnf" type="text" id="csnf" size="4" maxlength="4">
        年 
        <input name="csyf" type="text" id="csyf" size="2" maxlength="2">
        月 
        <input name="csri" type="text" id="csri" size="2" maxlength="2">
        日</td>
    </tr>
    <tr> 
      <td><input type="checkbox" name="checkbox5" value="address3">
        住 址 :</td>
      <td colspan="2"><input name="address" type="text" id="address3"></td>
    </tr>
    <tr> 
      <td><div align="center"> 
          <input type="submit" name="Submit" value="查询">
        </div></td>
      <td width="33%"><div align="center"> 
          <input type="reset" name="Submit2" value="重填">
        </div></td>
      <td width="48%"> <div align="left"> 
          <input type="button" name="Submit3" value="返回" onclick="javascript:window.history.go(-1)">
        </div></td>
    </tr>
  </table>
</form>
</body>
</html>

解决方案 »

  1.   

    <%@ Language=VBScript %>
    <!--#include file="../inc/doracle.asp"--><html>
    <head>
    <title>综合查询</title>
    <link rel="stylesheet" type="text/css" href="../inc/style.css">
    <script language="JavaScript">
       function verfy()
       {
         if ((document.form.id.value == "") && (document.form.name.value == "") && (document.form.address.value == "") )
          {
        alert("请您至少填写身份证号、姓名、暂住地址中的一项!");
        document.form.id.focus();
        return (false);
          }
         if (document.form.checkbox1.value != "")
          {
               if ((document.form.id.value == "") || (document.form.id.value.length !=18 && document.form.id.value.length !=10))
               {
           alert("请您填写正确的身份证号!");
           document.form.id.focus();
           return (false);
               }
          }
     if (document.form.checkbox4.value != "")
      {
               if ((document.form .csnf .value == "" )||(document.form .csnf .value  <= 1900 && document.form.csnf.value != ""))
                   {
                   alert("请填写正确年份");
                   document.form.csnf.focus();
                   return (false);
                   }
               if (isNaN(document.form .csyf .value )||(document.form.csyf.value != "" && document.form.csyf.value < 1 || document.form.csyf.value > 12))
                   {
                   alert("请填写正确的月份");
                   document.form.csyf.focus();
                   return (false);
                   }
               if (isNaN(document.form .csri .value )||(document.form.csri.value != "" && document.form.csri.value < 1 || document.form.csri.value > 31))
                   {
                   alert("请填写正确的日期");
                   document.form.csri.focus();
                   return (false);
                   }     
               if (!((document.form.csri .value =="" && document.form.csyf.value =="" && document.form .csnf .value =="")||(document.form.csri .value!="" && document.form.csyf.value!="" && document.form .csnf .value !="")))
                   {
                   alert("请填写完整有效时间");
                   document.form.csnf.focus ();
                   return (false);
                   }
          } 
       }
    </script>
    </head><body>
    <p>&nbsp; </p>
    <form name="form" action="zhshow.asp" method="post"  onsubmit="return verfy()">
      <table width="97%" border="0" align="center">
        <tr> 
          <td colspan="3">请在您所知的查询条件左边打勾,并在右边添入相应信息!</td>
        </tr>
        <tr> 
          <td width="19%">&nbsp;</td>
          <td colspan="2">*注意:需输入身份证号、姓 名、住 址中至少一个</td>
        </tr>
        <tr> 
          <td><input type="checkbox" name="checkbox1" value="id_no">
            身份证号:</td>
          <td colspan="2"><input name="id" type="text" id="id"></td>
        </tr>
        <tr> 
          <td><input type="checkbox" name="checkbox2" value="name">
            姓 名 :</td>
          <td colspan="2"><input name="name" type="text" id="name3"></td>
        </tr>
        <tr> 
          <td height="20"><input type="checkbox" name="checkbox3" value="sex_no">
            性 别 :</td>
          <td colspan="2"> <select name="sex">
              <option value="男">男</option>
              <option value="女">女</option>
            </select> </td>
        </tr>
        <tr> 
          <td><input type="checkbox" name="checkbox4" value="birthday">
            出生日期:</td>
          <td colspan="2"> 
            <input name="csnf" type="text" id="csnf" size="4" maxlength="4">
            年 
            <input name="csyf" type="text" id="csyf" size="2" maxlength="2">
            月 
            <input name="csri" type="text" id="csri" size="2" maxlength="2">
            日</td>
        </tr>
        <tr> 
          <td><input type="checkbox" name="checkbox5" value="address3">
            住 址 :</td>
          <td colspan="2"><input name="address" type="text" id="address3"></td>
        </tr>
        <tr> 
          <td><div align="center"> 
              <input type="submit" name="Submit" value="查询">
            </div></td>
          <td width="33%"><div align="center"> 
              <input type="reset" name="Submit2" value="重填">
            </div></td>
          <td width="48%"> <div align="left"> 
              <input type="button" name="Submit3" value="返回" onclick="javascript:window.history.go(-1)">
            </div></td>
        </tr>
      </table>
    </form>
    </body>
    </html>