本帖最后由 sir424 于 2009-10-29 10:30:38 编辑

解决方案 »

  1.   

    这样不知道行不行,你不如不用表单提交,用button 呢
      

  2.   


    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
            <title>Untitled Document</title>
            <script type="text/javascript">
                /**
                 * author: develop_design_level
                 * date: 2009-10-29
                 * @param {Object} id
                 */
                function $(id){
                    if (document.getElementById) {
                        return document.getElementById(id);
                    }
                    else {
                        return document.all.id;
                    }
                }
                
                window.onload = function(){
                    $('submit1Id').onclick = function(){
                        $('formId').submit();
                    };
                    $('submit2Id').onclick = function(){
                        var _value = $('endValueId').value;
                        if (_value == '') {
                            alert("请输入记录内容");
                            $('endValueId').focus();
                            $('endValueId').select();
                        }
                    };
                };
            </script>
        </head>
        <body>
            <form id="formId" name="form1" method="post" action="" onSubmit="return checkform();">
                <input type="button" value="添加" id="submit1Id">
                <br/>
                <input type="text" name="end" id="endValueId"/>
                <br/>
                <input type="button" value="提交" id="submit2Id">
            </form>
        </body>
    </html>
      

  3.   

    刚刚我写的代码不完整,不好意思,下面对不完整的地方进行了修正。if (_value == '') {
        alert("请输入记录内容");
        $('endValueId').focus();
        $('endValueId').select();
    }else{//刚才上面我写的那段代码,忘记写不为空时进行提交了。呵呵 这里补上
        $('formId').submit();
    }
      

  4.   

    在添加后边 加onclick调用验证js
      

  5.   

    补充:若出现"不允许用于访问路径“”的 HTTP 谓词 POST"错误,请做如下修改:<form id="formId" name="form1" method="get" action="" onSubmit="return checkform();">