0

What should be the code here if the user clicks the back button after submitting form, data must be reset.

Here is my code so far:

$('form').on('submit',function(){

  } else{

  }

});
Frits
  • 7,341
  • 10
  • 42
  • 60
krish
  • 120
  • 14
  • See [this](https://stackoverflow.com/questions/8701812/clear-form-after-submission-with-jquery) – Dhaval Marthak May 25 '17 at 05:29
  • https://stackoverflow.com/q/3786694/6521116 and https://stackoverflow.com/q/16452699/6521116 – LF00 May 25 '17 at 05:31
  • Possible duplicate of [How to reset (clear) form through JavaScript?](https://stackoverflow.com/questions/3786694/how-to-reset-clear-form-through-javascript) – LF00 May 25 '17 at 05:34

3 Answers3

1
$('form').on('submit',function(){
//YOUR ACTION GOES HERE
$('#YOURFORMID')[0].reset();
  } else{

  }

});
0

Form submit after response with add this line and form id

document.getElementById("formID").reset();
Khetesh kumawat
  • 681
  • 7
  • 15
  • sir document.getElementById("client").reset(); not working in chrome.In firefox its working – krish May 25 '17 at 05:41
0
$(':input','#myform')
 .not(':button, :submit, :reset, :hidden')
 .val('')
 .removeAttr('checked')
 .removeAttr('selected');

Or

$('#myform')[0].reset();
Milan Chheda
  • 8,159
  • 3
  • 20
  • 35