</pre>submit与onsubmit<a target=_blank target="_blank" href="http://shihuan830619.iteye.com/blog/2249028">原文</a><br style="font-family:Helvetica,Tahoma,Arial,sans-serif; font-size:14px; line-height:25.2000007629395px" /><br style="font-family:Helvetica,Tahoma,Arial,sans-serif; font-size:14px; line-height:25.2000007629395px" /><span style="font-family:Helvetica,Tahoma,Arial,sans-serif; font-size:14px; line-height:25.2000007629395px">发生顺序:onsubmit -> submit </span><br style="font-family:Helvetica,Tahoma,Arial,sans-serif; font-size:14px; line-height:25.2000007629395px" /><p></p><pre name="code" class="html">1.阻止表单提单:
<script>
function submitFun(){
//逻辑判断
return true; //允许表单提交
//逻辑判断
return false;//不允许表单提交
}
</script>
<form οnsubmit="return submitFun();"> //注意此处不能写成 οnsubmit="submitFun();"否则将表单总是提交
</form>
2.onsubmit()与submit() :
<script>
function fun()
{
alert("form_submit");
}
</script>
<form οnsubmit="fun()">
<input type="submit" id="aaa" value="submit"> <!--能弹出form_submit-->
<input type="button" id="bbb" value="onCliCk_submit" onCliCk="doCument.forms[0].submit()">
<!--
表单会提交,但是不会运行fun() 原因是 onsubmit事件不能通过此种方式触发(在IE环境)
直接用脚本doCumetn.formName.submit()提交表单是不会触发表单的onsubmit()事件的
-->
<input type="button" id="bb1" value="onCliCk_onsubmit" onCliCk="doCument.forms[0].onsubmit()">
<!--会触发fun()参数-->
</form>
记录开发过程中的点滴!