return false  之后代码是不执行了
但仍然提交到新的页面

解决方案 »

  1.   

    <form name=f onsubmit="return checkme()">
    ....
    </form>
    <script>
    function checkme()
    {
    if(document.f.text1.value=="")
    {
    alert("不能为空")
     return false
    }if(document.f.text2.value=="")
    {
    alert("不能为空")
     return false
    }
    return true
    }
    </script>
      

  2.   

    <form name=f onsubmit="return checkme()" method="post" action="test.asp" target="_blank">
    <input name=text1>
    <input name=text2>
    <input type=submit>
    </form>
    <script>
    function checkme()
    {
    if(document.f.text1.value=="")
    {
    alert("不能为空")
     return false
    }if(document.f.text2.value=="")
    {
    alert("不能为空")
     return false
    }
    return true
    }
    </script>