原代码:
<html>
<head>
<script language="JavaScript">  <!--function go(o,n) {
  if (o.value.length>=3 && n!=null)
    document.myForm.elements[n].focus();
  doValidate();
}function doValidate() {
  var isValid = true;
  for (var i=0; i<document.myForm.length;i++) {
    var items = document.myForm.elements[i];
    if (items.value.length==0) {
      isValid = false;
      break;
    }
  }
  if (isValid) 
  {document.myForm.elements["s1"].disabled = false;}
}  //--></script>
</head>
<body>
<form name="myForm"  method="POST"   action=""  onsubmit="if(t1.value.length<1){alert('请输入的密码大于1');return false;};else return true;">  
  <input type="text" name="t1" maxlength="3" size="3" onkeyup="go(this,'t2');value=value.replace(/[^\d]/g,'')">
  <input type="text" name="t2" maxlength="3" size="3" onKeyUp="go(this,'t3');value=value.replace(/[^\d]/g,'')">
  <input type="text" name="t3" maxlength="3" size="3" onKeyUp="go(this,'t4');value=value.replace(/[^\d]/g,'')">
  <input type="text" name="t4" maxlength="3" size="3" onKeyUp="go(this);value=value.replace(/[^\d]/g,'')">
  <input type="submit" name="s1" value="提交喔!" disabled>
</form>
  <form   method="POST"   action=""   onsubmit="if(k1.value.length<1){alert('请输入的密码大于1位')}">   
      <p><input   type="text"   name="k1"   size="20">
         <input   type="submit"   value="提交"   name="B1"> </p>   
  </form>  
</body>
</html>
====================================================================================================下面的那个表单能触发提交窗体~`
可是myform表单就不能触发的`
这是为什么``
如何才能设置到~
`当t1,t2,t3,t4文本框的长度少于1时~
就提示:请输入至少一个数字!
头痛呀~
`一下午都未搞掂呀~`
看看你们怎么修改好了`~

解决方案 »

  1.   

    <form name="myForm"  method="POST"   action=""  onsubmit="if(myForm.t1.value.length<3){
    alert('请输入的密码大于1');
    return false;
      }
                                                              return true;">   
       <input type="text" name="t1" maxlength="3" size="3" onkeyup="go(this,'t2');"> 
       <input type="text" name="t2" maxlength="3" size="3" onKeyUp="go(this,'t3');"> 
       <input type="text" name="t3" maxlength="3" size="3" onKeyUp="go(this,'t4');"> 
       <input type="text" name="t4" maxlength="3" size="3" onKeyUp="go(this);"> 
       <input type="submit" name="s1" value="提交喔!" disabled> 
    </form> 
      

  2.   

    <html> 
    <head> 
    <script language="JavaScript">   <!-- function go(o,n) { 
      if (o.value.length>=3 && n!=null) 
        document.myForm.elements[n].focus(); 
      doValidate(); 
    } function doValidate() { 
      var isValid = true; 
      for (var i=0; i <document.myForm.length;i++) { 
        var items = document.myForm.elements[i]; 
        if (items.value.length==0) { 
          isValid = false; 
          break; 
        } 
      } 
      if (isValid)  
      {document.myForm.elements["s1"].disabled = false;} 
    }  //--> </script> 
    </head> 
    <body> 
    <form name="myForm"  method="POST"   action=""  onsubmit="if(myForm.t1.value.length<3){
    alert('请输入的密码大于1');
    return false;
      }
                                                              return true;">   
       <input type="text" name="t1" maxlength="3" size="3" onkeyup="go(this,'t2');value=value.replace(/[^\d]/g,'')"> 
       <input type="text" name="t2" maxlength="3" size="3" onKeyUp="go(this,'t3');value=value.replace(/[^\d]/g,'')"> 
       <input type="text" name="t3" maxlength="3" size="3" onKeyUp="go(this,'t4');value=value.replace(/[^\d]/g,'')"> 
       <input type="text" name="t4" maxlength="3" size="3" onKeyUp="go(this);value=value.replace(/[^\d]/g,'')"> 
       <input type="submit" name="s1" value="提交喔!" disabled> 
    </form> 
       <form   method="POST"   action=""   onsubmit="if(k1.value.length <1){alert('请输入的密码大于1位')}">    
           <p> <input   type="text"   name="k1"   size="20"> 
              <input   type="submit"   value="提交"   name="B1">  </p>    
       </form>   
    </body> 
    </html> 
      

  3.   

    <html> 
    <head> 
    <script language="JavaScript">   
    <!-- 
    var isValid=true;
    function go(o,n) { 
      if (o.value.length>=3){ 
        document.myForm.elements[n].focus(); 
        doValidate(); 
      }else{
        alert('请输入的密码大于1');
        isValid=false;
        o.focus();
      }
      o.value=o.value.replace(/[^\d]/g,'')
    }function doValidate() {  
      for (var i=0; i <document.myForm.length;i++) { 
        var items = document.myForm.elements[i]; 
        if (items.value.length==0) { 
          isValid = false; 
          break; 
        } 
      } 
     
    }function checkSubmit(){
        if (isValid){
          document.myForm.elements["s1"].disabled = false;
          return false;
        }
        return true;
    }  
    //--> 
    </script> 
    </head> 
    <body> 
    <form name="myForm"  method="POST"   action="#"  onsubmit="return checkSubmit();">   
       <input type="text" name="t1" maxlength="3" size="3" onblur="go(this,'t2')"> 
       <input type="text" name="t2" maxlength="3" size="3" onblur="go(this,'t3');"> 
       <input type="text" name="t3" maxlength="3" size="3" onblur="go(this,'t4');"> 
       <input type="text" name="t4" maxlength="3" size="3" onKeyUp="go(this);value=value.replace(/[^\d]/g,'')"> 
       <input type="submit" name="s1" value="提交喔!" disabled> 
    </form> 
       <form   method="POST"   action=""   onsubmit="if(k1.value.length <1){alert('请输入的密码大于1位')}">    
           <p> <input   type="text"   name="k1"   size="20"> 
              <input   type="submit"   value="提交"   name="B1">  </p>    
       </form>   
    </body> 
    </html>