onsubmit code example
Example 1: onsubmit in html
<form onsubmit="myFunction()">
Enter name: <input type="text">
<input type="submit">
</form>
<script>
function myFunction() {
alert("The form was submitted");
}
</script>
Example 2: javascript submit form
document.forms["myform"].submit();