html form on submit code example

Example 1: html submit button

<input type="submit" value="Submit">

Example 2: html submit form onclick

var form = document.getElementById("form-id");

document.getElementById("your-id").addEventListener("click", function () {
  form.submit();
});

Example 3: how to run js before submit html

<form onsubmit="return do_something()">

function do_something(){
   // Do your stuff here
   return true; // submit the form

   return false; // don't submit the form
}

Example 4: javascript submit form

document.forms["myform"].submit();

Example 5: submit html

<input type="submit">

Example 6: how to use form on submit in html

<form onsubmit="myFunction()">
  Enter name: <input type="text">
  <input type="submit">
</form>