你不要写到事件里面去,直接把BUTTON的类型改了就可以了。
<BUTTON name="1" type="reset">form.reset() </BUTTON>
<BUTTON name="2" type="submit" >form.submit() </BUTTON>
<BUTTON name="1" type="reset">form.reset() </BUTTON>
<BUTTON name="2" type="submit" >form.submit() </BUTTON>
[align=center]==== 思想重于技巧 ====
[/align]
IE中form.submit()不会触发 onsubmit()事件。 -- 引自MSDN
[align=center]==== 思想重于技巧 ====
[/align]
<html>
<head>
<title> New Document </title>
<script>
</script>
</head> <body>
<script language="javascript"> function doSubmit(){
window.alert("I will be Submit");
} </script>
<form name="form1" onsubmit="doSubmit();">
<b>Enter some text: </b> <br> <button name="2" onclick="333">333 </button>
</form>
</body>
</html>
再看看下面这个
多了<![CDATA[ 这个东西,上面的写法不符合XHTML规范<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title> New Document </title>
<script>
</script>
</head> <body>
<script language="javascript">
<![CDATA[
function doSubmit(){
window.alert("I will be Submit");
}
]]>
</script>
<form name="form1" onsubmit="doSubmit();">
<b>Enter some text: </b> <br> <button name="2" onclick="333">333 </button>
</form>
</body>
</html>
最后 submit用下面这种方法
<form id="addoperator" action="operatorManager" mehtod="post" onsubmit="return check()">
<button type="submit"> 确定</button>
<button type="reset">取消</button>
</form>
或者
<button type="button" onclick="aaa()">确定</button>function aaa(){
//some check
document.forms[0].action=...
document.forms[0].submit()
}
<html>
<head>
<title> New Document </title>
<script>
</script>
</head> <body>
<script language="javascript"> </script>
<form name="form1" action="http:\\www.baidu.com" >
<b>Enter some text: </b>
<input type="text" id="txt" value="">
<input type="submit" value="提交">
<input type="reset" value="重置">
</form>
</body>
</html>看下这个