<script>
function checkForm()
{ if (document.form1.startdate.value=="" || document.form1.enddate.value =="")
{ alert("Please select start date! ");
document.form1.startdate.focus() ;
 event.returnValue= false;} 
}
</script>
<form name=form1>
<input id=startdate>
<input id=enddate>
 <input class="button" type="submit" name="Submit" value="Submit" onclick="return checkForm()">
</form>

解决方案 »

  1.   

    是因为你这一句document.form1.startdate.focus 漏了括号,脚本运行错误,所以ie停止执行下面的脚本,也就没有return false,造成还是能够提交。
      

  2.   

    你在<form>这里调用这个事件onsubmit=return checkForm();
      

  3.   

    <script>function checkForm()

    if (document.form1.startdate.value  =="" || document.form1.enddate.value !="")

    alert("Please select start date! ");
    document.form1.startdate.focus ;
     return false;

    return true
    }
    </script>
    <form name=form1 onsubmit="return checkForm()">
    <input id=startdate>
    <input id=enddate>
     <input class="button" type="submit" name="Submit" value="Submit">
    </form>
      

  4.   

    form内部的input一般用name,而不是id,
    条件有无错误?<script>
    function checkForm()

    if (document.form1.startdate.value  =="" || document.form1.enddate.value =="")

    alert("Please select start date! ");
    document.form1.startdate.focus();
     return false;

    return true
    }
    </script>
    <form name=form1 onsubmit="return checkForm()">
    <input name=startdate>
    <input name=enddate>
     <input class="button" type="submit" value="Submit">
    </form>
      

  5.   

    好像还是不行,报错说 ,"'return' type mismatch"
      

  6.   

    <script language=javascript>
    function checkForm()
    { if (document.form1.startdate.value=="" || document.form1.enddate.value =="")
     { 
      alert("Please select start date! ");
      return false;
     }
     window.form.submit();
     return true 
    }
    </script>
    <form name=form1>
    <input name=startdate>
    <input name=enddate>
     <input class="button" type="submit" name="Submit1" value="Submit1" onclick="javascript:checkForm()">
    </form>
      

  7.   

    你把
    <input class="button" type="submit" name="Submit" value="Submit" onclick="return checkForm()">
    换成
    <form .... onsubmit="return checkFrom()">  试试 还有,你页面里没有重名函数吧?