注意写上return
<form action="" method="post" name="myform" onsubmit="return check()">

解决方案 »

  1.   

    你是点什么直接执行表单提交的?
    我觉得加个button 来提交
     <input type="button"  onclick="check();" value="提交" />这样没问题。
      

  2.   

    <form action="" method="post" name="myform" onsubmit="check()"> 
    改成下面的
    <form action="xxx.aspx" method="post" name="myform" onsubmit="return check();"> 
    或者
    <form action="" method="post" name="myform" onclick="return check();" > 
    http://bbsanwei.iteye.com/blog/271547
     http://liuzhen.liujie.blog.163.com/blog/static/1275561562012729104825183/
      

  3.   

    <form action="" method="post" name="myform" onclick="return check();" >  try 
      

  4.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>第一个简单的jQuery程序</title> 
     
     <script language="JavaScript" type="text/javascript">
    function check(){
     var email=document.getElementById("email").value;
     if(email==""){
    alert("email不能为空");
    return false; 
     }
     if(email.indexOf("@")==-1||email.indexOf(".")==-1){
     alert("email格式不正确");
     return false;
     }
      var pwd=document.getElementById("password").value;
      if(pwd==""){
      alert("密码不能为空");
      return false;
      }
       if(pwd.length<6){
       alert("密码必须大于6位");
       return false;
       }
     var repwd=document.getElementById("repassword" ).value;//这里没有value
     if(repwd!=pwd){
     alert("密码不一致");
     return false;
     }
    var user=document.getElementById("user").value;
    if(user==""){
    alert("姓名不能为空");
    return false;
    }
    for(var i=0;i<user.length;i++){
    var j=user.substring(i,i+1);
    if(isNaN(j)==false){
    alert("姓名中不能包含数字");
    return false;
    }
    }
    return true;
    }  </script>
    </head>
    <body>
     <form action="" method="post" name="myform" onsubmit="return check();">
        <tr>   
           <td>你的Email:</td>
           <td><input id="email"  type="text" name="email" class="input-text" /> </td>   
        </tr>
        <tr>
           <td>输入密码:</td>
           <td><input id="password" type="password" name="password" class="input-text" /> </td>
        </tr>
        <tr>
           <td>确认密码:</td>
           <td><input  id="repassword" type="password" name="repassword" class="input-text" /> </td>
    <!-- 这里名字写错了 -->
        </tr>
        <tr>
           <td>用户名:</td>
           <td><input  id="user" type="text" name="name" class="input-text" /> </td>
        </tr>
    <input type="submit" value="tijiao"/>
        </form>
    </body>
    </html>
      

  5.   

    <form action="" method="post" name="myform" onclick="return check();" >  try 
    不行~~
      

  6.   

    点击查看演示代码,已经测试过了,把你的js放在放在head里面
    <form action="" method="post" name="myform" onclick="return check();" >  try 
    不行~~
      

  7.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
     <head>
      <title>test</title>  
    <style type="text/css"></style>
    <script type="text/javascript">
    function check(){
     var email=document.getElementById("email").value;
     if(email==""){
    alert("email不能为空");
    return false; 
     }
     if(email.indexOf("@")==-1||email.indexOf(".")==-1){
     alert("email格式不正确");
     return false;
     }
      var pwd=document.getElementById("password").value;
      if(pwd==""){
      alert("密码不能为空");
      return false;
      }
       if(pwd.length<6){
       alert("密码必须大于6位");
       return false;
       }
     var repwd=document.getElementById("repassword" );
     if(repwd!=pwd){
     alert("密码不一致");
     return false;
     }
    var user=document.getElementById("user").value;
    if(user==""){
    alert("姓名不能为空");
    return false;
    }
    for(var i=0;i<user.length;i++){
    var j=user.substring(i,i+1);
    if(isNaN(j)==false){
    alert("姓名中不能包含数字");
    return false;
    }
    }
    return true;
    }
    </script>
    </head>
    <body>
    <form action="" method="post" name="myform" onsubmit="check();">
    <table>
        <tr>   
           <td>你的Email:</td>
           <td><input id="email"  type="text" name="email" class="input-text" /> </td>   
        </tr>
        <tr>
           <td>输入密码:</td>
           <td><input id="password" type="password" name="password" class="input-text" /> </td>
        </tr>
        <tr>
           <td>确认密码:</td>
           <td><input  id="repassword" type="password" name="password" class="input-text" /> </td>
        </tr>
        <tr>
           <td>用户名:</td>
           <td><input  id="user" type="text" name="name" class="input-text" /> </td>
        </tr>
    </table>
    <input type="submit" value="submit" />
        </form>
    </body>
    </html>