因为你"ctrl+回车"触发了ctlent(),并且回车也触发了submit按钮,又执行一次checkform()

解决方案 »

  1.   

    this.document.form1.submit();
    去掉试试
      

  2.   

    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <script>
    //表单验证
    function checkform(){
      with(form1){
        if(name.value==''){
      alert('Please input your username.');
      name.focus();
      return false;
    }if(password.value=='' || password.value.length<6){
      alert('It needs 6 charectors at least your password.');
      password.focus();
      return false;
    }
    return true;
      }
    }//快捷键提交表单
    ie=(document.all)?true:false;
    if(ie){
     function ctlent(eventobject){
        if(event.ctrlKey && window.event.keyCode==13){//ctrl+回车
      if(checkform()) this.document.form1.submit();
    }
      }
      //document.body.onkeydown=ctlent;//相当于在<body>标签内加onkeydown="ctlent();",但此处不能加括号()
    }
    function submit_onclick(){
      if(checkform()){
         document.form1.submit(); 
    }
      
    }
    </script></head><body onkeydown="ctlent();">
    <form action="login.asp" method=POST name=form1 onsubmit="return checkform();">
    username: <input type="text" name="name" size="20" value=""><br/>
    password: <input type="password" name="password" size="20" value=""><br/>
    &nbsp;&nbsp;<input type="button" value="submit" onclick="submit_onclick()"><span style="font-size:12px">(也可用Ctrl+enter提交表单)</span>
    </form>
    </body>
    </html>
    改写submit部分