How to Stop Confirm Form Resubmission?

Javascript, PHP

We can submit our Forms in many ways like using Form action to URL of other page on same website, Form action to URL of other website, Form action to URL of same page on same website. When we submit our Form on same page. Then there is a possibility that the form can be resubmit during page refresh or page reload. So, In this article we will work on how to stop confirm form resubmission.

We can stop confirm form resubmission using the JavaScript. We will check the history state using the window.history.replaceState. The History.replaceState() method modifies the current history entry, replacing it with the stateObj, title, and URL passed in the method parameters. If there is a replaceState then we will replace the current history with current page URL.

To do this Just paste the code given below before closing body tag( </body>) in footer of web page.

<script>
   if ( window.history.replaceState ) {
	window.history.replaceState( null, null, window.location.href );
   }
</script>

Read For More JavaScript Tutorials and Code, PHP Tutorials and Code.

If you like this, share this.

Follow us on FacebookTwitterTumblrLinkedIn.