onsubmit="return datacheck()"> // 放在这里比较好 

解决方案 »

  1.   

    Q1:你把按钮放到了<form>之外,当然就失效了;把按钮放进去,用FORM的ONSUBMIT 或按钮的ONCLICK  都可以;
    Q2:2.asp应该没最小化,是焦点转移到父窗口挡住2.asp了吧;没有回传参数需要的话,用SHOWDIALOGMODAL
      

  2.   

    1、按钮在<form>内  不行啊
      

  3.   

    按钮用不着了
    <form   name="1"   method="post"   action="2.asp"   traget="_blank"   onsubmit="return datacheck()"> 
    </form> 
    第二个问题。。是不是你在window.open()//里面的参数设置了让窗口最小化?
    如果不是,那么就是你的浏览器保留了你的浏览习惯,新开的窗口总是最小化~如果是这种情况,你在把所有浏览器窗口全部关闭,关闭最后一个的时候保存的窗口状态就是下一次启动浏览器新窗口的启动状态了~~我猜是这样~
      

  4.   

    这是 我的<script language="javascript">
    function datacheck() {
       if (document.input1.sxhh.value==0 && document.input1.sxhh.value =="") {
           alert("手写货号不能为空");
       document.input1.sxhh.focus();
       return ;
    }
    }
    </script>
    在表单内<input type=submit onclick="datacheck()">  虽然会弹出"手写货号不能为空"的对话框  但是 程序还会执行下去 没起作用??
      

  5.   

    he_8134  
    第一  我的<form       name="1"       method="post"       action="2.asp"       traget="_blank"       onsubmit="return   datacheck()">   
    </form>   中已经有onsubmit 其他事件  
    第二:
    二楼的toury 说得没错 2.asp 是没最小化  只是被1.asp给挡住了??
    有没有什么办法是2.asp 始终获得焦点????
      

  6.   


    <script   language="javascript"> 
    function datacheck() { 
        if(document.input1.sxhh.value==0&&document.input1.sxhh.value==""){ 
            alert("手写货号不能为空"); 
            document.input1.sxhh.focus(); 
            return false; 
        }
        return true;

    </script> <input   type=submit   onclick="return datacheck()" />  
      

  7.   

    he_8134 还是不行啊 弹出alert("手写货号不能为空");  信息后  还是会接着弹出2.asp 窗口  
      

  8.   

    java2000_net  window.opener.focus();  
    我的意思是使2.asp 在1.asp上面  而不是相反的
      

  9.   

    楼主肯定在别的地方有错~~你试试下面的代码~~<form action="http://baidu.com">
    <input type="text" id="txt" />
    <input type="submit" onclick="return check()" value="提交"/>
    </form>
    <script>
    function check(){
        var txt=document.getElementById("txt").value;
        if(txt==""){
           alert("不能为空");return false;
        }
        return true;
    }
    </script>
      

  10.   

    这样还是不行的  alert 确定后 还是会执行 2.asp    因为有target="_blank"
      

  11.   

    加了target="_blank"也可以
    <form action="http://baidu.com" target="_blank">
    <input type="text" id="txt" />
    <input type="submit" onclick="return check()" value="提交"/>
    </form>
    <script>
    function check(){
        var txt=document.getElementById("txt").value;
        if(txt==""){
           alert("不能为空");return false;
        }
        return true;
    }
    </script>
      

  12.   

    但是<script>
    function check(){
        var txt=document.getElementById("txt").value;
        if(txt==""){
           alert("不能为空");return false;
        }
        return true;
    }
    </script>
      在txt 的后面还有很多的数据项需要检查阿!!我就改为function check(){
        var txt=document.getElementById("txt").value;
        if(txt==""){
           alert("不能为空");return false;
        }
        return true;
    var txt=document.getElementById("txt").value;
        if(txt==""){
           alert("不能为空");return false;
        }
        return true;var txt=document.getElementById("txt").value;
        if(txt==""){
           alert("不能为空");return false;
        }
        return true;}
    </script>
    怎么不行呢?
      

  13.   


    <script> 
    function check(){ 
        if(document.getElementById("txt").value==""){ 
          alert("txt不能为空");return false; 
        } 
        else if (document.getElementById("txt1").value==""){ 
          alert("txt1不能为空");return false; 
        } 
        else if (document.getElementById("txt2").value==""){ 
          alert("txt2不能为空");return false; 
        } 
        else if (document.getElementById("txt3").value==""){ 
          alert("txt3不能为空");return false; 
        } 
        //如果还有继续重复 else if
        //.....

    </script> 
      

  14.   

        在txt   的后面还有很多的数据项需要检查阿!!我就改为function   check(){ 
            var   txt=document.getElementById("txt").value; 
            if(txt==""){ 
                  alert("不能为空");return   false; 
            } 
            return   true; 
    var   txt=document.getElementById("txt").value; 
            if(txt==""){ 
                  alert("不能为空");return   false; 
            } 
            return   true; var   txt=document.getElementById("txt").value; 
            if(txt==""){ 
                  alert("不能为空");return   false; 
            } 
            return   true; 在检查下一项之前你用了return,当然就不行了,呵呵