formのsubmitとonsubmitの用法と違い
1167 ワード
submitとonsubmit
発生順序:onsubmit->submit
発生順序:onsubmit->submit
1. :
<script>
function submitFun(){
//
return true; //
//
return false;//
}
</script>
<form onsubmit="return submitFun();"> // onsubmit="submitFun();"
</form>
2.onsubmit() submit() :
<script>
function fun()
{
alert("form_submit");
}
</script>
<form onsubmit="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>