if(txt1.value=="" && txt2.value=="" && txt3.value=="" && txt4.value=="")
{
  alert("sth.");
  return false;
}

解决方案 »

  1.   

    <div id="jia">
    <input type="text" name="jia1" id="jia1"><br>
    <input type="text" name="jia2" id="jia2"><br>
    <input type="text" name="jia3" id="jia3"><br>
    <input type="text" name="jia4" id="jia4"><br><input type="button" value="check" onclick="chk();">
    </div><script language="javascript">
    function chk(){
    var txt1 = document.getElementById("jia1").value;
    var txt2 = document.getElementById("jia2").value;
    var txt3 = document.getElementById("jia3").value;
    var txt4 = document.getElementById("jia4").value;

    if (!txt1 && !txt2 && !txt3 && !txt4){
    alert("至少填一个");
    return;
    }else{
    alert("ok");
    //提交表单;
    }
    }
    </script>
      

  2.   

    如果是form表单提交,用:document.formname.submit();
    如果是连接提交:你的函数返回true时候就可以继续走了,如果返回的是false 则连接不起作用
      

  3.   

    看好了
    <form method=post><div id="jia">
    <input type="text" name="jia1" id="jia1"><br/>
    <input type="text" name="jia2" id="jia2"><br/>
    <input type="text" name="jia3" id="jia3"><br/>
    <input type="text" name="jia4" id="jia4"><br/><input type="submit" value="check" onclick="return chk();">
    </div>
    </form><script language="javascript">
    function chk(){
    var txt1 = document.getElementById("jia1").value;
    var txt2 = document.getElementById("jia2").value;
    var txt3 = document.getElementById("jia3").value;
    var txt4 = document.getElementById("jia4").value;if (!txt1 && !txt2 && !txt3 && !txt4){
    alert("至少填一个");
    return;
    }else{
    alert("ok");
    //提交表单;
    }
    }
    </script>
      

  4.   

    <script language="javascript">
    function chk(){
    var txt1 = document.getElementById("brand").value;
    var txt2 = document.getElementById("schour").value;if (!txt1 && !txt2){
    alert("至少填一个");
    return;
    }else{
    alert("ok");
    //提交表单;
    }
    }
    </script>
    <form name="form1" method="post" action="demand.asp">
    <input name="brand" type="text" id="brand">
    <input name="schour" type="text" id="schour">
    <input type="submit" name="Submit" value="查 询" onclick="return chk();">
          </form>判断为空后还是会跳转到demand.asp页面,而我是想当一个文本域有内容后才能跳转过去。
      

  5.   

    <script language="javascript">
    function chk(){
    var txt1 = document.getElementById("brand").value;
    var txt2 = document.getElementById("schour").value;if (!txt1 && !txt2){
    alert("至少填一个");
    return false;
    }else{
    alert("ok");
    //提交表单;
    }
    }
    </script>
    <form name="form1" method="post" action="demand.asp">
    <input name="brand" type="text" id="brand">
    <input name="schour" type="text" id="schour">
    <input type="submit" name="Submit" value="查 询" onclick="return chk();">
    </form>