Order of Occurrence: onsubmit, submit
1. Prevent form Bill of lading:
<script>
function Submitfun () {
Logical judgment
return true; Allow form submission
Logical judgment
Return false;//does not allow form submission
}
</script>
<form onsubmit= "Reture submitfun (); >//Note This cannot be written as onsubmit= "Submitfun ();" Otherwise, always submit the form
</form>
2.onsubmit () and submit ():
<script>
function Fun ()
{
Alert ("Form_submit");
}
</script>
<form onsubmit= "Fun ()" >
<input type= "Submit" id= "AAA" value= "Submit" > <!--can eject form_submit-->
<input type= "button" id= "BBB" value= "Onclick_submit" onclick= "Document.forms[0].submit ()" >
<!--
The form will be submitted, but will not run fun () because the onsubmit event cannot be triggered in this way (in IE environment)
Submitting a form directly with the script DoCumetn.formName.submit () will not touch the onsubmit () event of the publication order.
-
<input type= "button" id= "BB1" value= "Onclick_onsubmit" onclick= "Document.forms[0].onsubmit ()" >
<!--will trigger fun () Parameters--
</form>
The use and difference of the form's Submit and onsubmit