<script language="javascript">
function chkid(checkStr) {
  var checkOK ="0123456789";
  return(chkstring(checkStr, checkOK));
}
function chkstring(checkStr, checkOK) {
  var allValid = true;
  if (typeof(checkStr) != "string" || typeof(checkOK) != "string") return(false);
  for (i = 0; i < checkStr.length; i++) {
    ch = checkStr.charAt(i);
    if (checkOK.indexOf(ch) == -1) {
      allValid = false;
      break;
    }
  }
  return(allValid);
}function check(){
if (chkid(document.form1.a.value)==false)
   {
     alert("输入不规范.");
 document.form1.a.focus();
 return false;
   }
}
</script><form name="form1" method="post" action="abc.asp" onsubmit="return check()">
    请输入证号:
    <input name="a" type="text" id="a" size="20" onclick=vbscript:show(me)>
    <input name="Submit" type="submit" value="确定">
</form>

解决方案 »

  1.   

    <script language="javascript">
    function chkid(checkStr) {
      var checkOK ="0123456789";
      return(chkstring(checkStr, checkOK));
    }
    function chkstring(checkStr, checkOK) {
      var allValid = true;
      if (typeof(checkStr) != "string" || typeof(checkOK) != "string") return(false);
      for (i = 0; i < checkStr.length; i++) {
        ch = checkStr.charAt(i);
        if (checkOK.indexOf(ch) == -1) {
          allValid = false;
          break;
        }
      }
      return(allValid);
    }function check(){
    if (chkid(document.form1.a.value)==false)
       {
         alert("输入不规范.");
     document.form1.a.focus();
     return false;
       }
    }
    </script><form name="form1" method="post" action="abc.asp" onsubmit="return check()">
        请输入证号:
        <input name="a" type="text" id="a" size="20">
        <input name="Submit" type="submit" value="确定">
    </form>
      

  2.   

    明白了,关键在这 
    return false;