form not refresh on submit code example

Example 1: form confirm before submit

<form 
    method="post"
    onSubmit="return confirm('Are you sure you wish to delete?');">
...
</form>

Example 2: how to make form not reload page

<form onsubmit="return false">
</form>

Example 3: why does my page reloads on form submission

//jquery method //
//preventDefault() prevents the submit button
//from performing its default task like page reload  
  $('#form').submit(function (e) {
      e.preventDefault();
  });

Example 4: javascript do not submit form

alert("hello world");
alert("it is a test");

Tags:

Html Example