HTML JS

RESET HTML FORM AFTER SUBMISSION

(quick guide & examples)

<form id="demo" autocomplete="off"             onsubmit="return process()">

AUTOCOMPLETE OFF

01

</form>

  WILL RESET TO "JON"   <input type="text" name="name"   value="Jon">

  WILL REVERT TO BLANK   <input type="email" name="email">

  GO!   <input type="submit" value="Go!">

function process () {   GET FORM DATA     var f = document.getElementById("data"),         d = new FormData(f);

JAVASCRIPT AJAX SUBMIT

02

  AJAX SEND FORM   fetch("URL", { method: "POST", body: d })   .then(res => res.text())   .then(txt => {     console.log(txt);     f.reset(); RESET FORM   });   return false; }