1.<input type=submit >submit按钮
2.<input type=text>当form中只有一个文本本框按回车的时候
3.<input type=button onclick=javascript:form1.submit()>自己写脚本提交还有在js里的提交事件

解决方案 »

  1.   

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>无标题文档</title>
    </head>
    <script language="javascript">
    function  aa(){ alert("aa")}
    function  ss(){  aa(); alert("ss");form1.submit()}
    </script>
    <body>
    <form name="form1" method="post" action="#" onSubmit="aa()">
      <input type="text" name="textfield">
      <input type="submit" name="Submit" value="提交">
      <input type="button" name="Submit2" value="按钮" onClick="ss()">
    </form>
    </body>
    </html>
      

  2.   

    页面上有各种提交的方式, 不确定的, 我不想修改页面,因为有很多页面,所以我想有一个js lib 捕获所有的提交事件, 如果是提交事件, 做一些额外的工作
      

  3.   

    ttyp
    ----
    好外没冒泡啊
      

  4.   

    因为只说form的事件,所以可以考虑遍历表单
    <html>
    <head>
    <meta http-equiv="content-type" content="text/html; charset=gb2312"/>
    <link rel="stylesheet" href=".css"/>
    <title>New Document</title>
    <style type="text/css">
    <!---->
    </style>
    <script type="text/javascript">
    <!--function frmSub(frm){
        alert("注意注意," + frm.id + " 要提交了");
    }
    window.onload = function(){
        var frms = document.forms;
        for(var i=0;i<frms.length;i++){
            var existHandle = frms[i].onsubmit;
            if(existHandle instanceof Function){
                frms[i].onsubmit = function(){iwantdootherthing(); existHandle();};
            }
        }
    }function iwantdootherthing(){
        alert("嘿嘿,偷偷先干点事儿!");
    }
    //-->
    </script>
    <body>
    <form id="frmData" method="post" action="" target="" onsubmit="frmSub(this)">
        <input type="text" id="" name="">
        <input type="submit" value="Submit">
    </form>
    </body>
    </html>