<html>
<script  language="javascript">  
function  CheckForm(){    
if(document.form1.name.value.length == 0)  {    
alert("请输入您姓名!");  
document.form.name.focus();  
return false;  
}  
return  true;  
}  
</script>
<head>
</head><body>
<form action="a.php" method="post" name="form1" onSubmit="CheckForm()">
name:<input type="text" id="name" name="name"/><br>
tel:<input type="text" id="tel" name="tel"/><br>
email:<input type="text" id="email" name="emain"/><br>
<input type="submit" name="submit"/>
</form>
</body>
</html>

解决方案 »

  1.   

    document.form.name.focus();   
    改成
    document.form1.name.focus();   
      

  2.   

    你的判断里面,只是检查name的长度为0时,不跳转,你说的输入错误是什么?
      

  3.   

    <script language="javascript">  
    function CheckForm(){  
    if(document.form1.name.value.length == 0) {  
    alert("请输入您姓名!");  
    document.form.name.focus();  
    return false;  
    }  
    return true;  
    }  
    </script>
    改成
    <script language="javascript">  
    function CheckForm(){  
    if(document.form1.name.value.length == 0) {  
    alert("请输入您姓名!");  
    document.form.name.focus();  
    return false;  
    }  
    else{
    return true;  
    }
    }  
    </script>
    还有<script></script>代码最好放在<head></head>里面!
      

  4.   

    <form action="a.php" method="post" name="form1" onSubmit="return CheckForm()">
      

  5.   


    <html>
    <script language="javascript">  
    function CheckForm(){  
    if(document.form1.name.value.length == 0) {  
    alert("请输入您姓名!");  
    document.form1.name.focus();  //form1
    return false;  
    }  
    return true;  
    }  
    </script>
    <head>
    </head><body>
    <form action="a.php" method="post" name="form1" onSubmit="return CheckForm()">//这里要return
    name:<input type="text" id="name" name="name"/><br>
    tel:<input type="text" id="tel" name="tel"/><br>
    email:<input type="text" id="email" name="emain"/><br>
    <input type="submit" name="submit"/>
    </form>
    </body>
    </html>