Use the preventDefault() method on the event object to prevent a page refresh on form submit in React, e.g. event. preventDefault() . The preventDefault method prevents the browser from issuing the default action which in the case of a form submission is to refresh the page.One way to stop page resubmission on page refresh is to unset the form data after it is submitted so that the variable storing form data becomes empty and wrap up your form processing block of codes to check if the form is empty. if (!empty ($_POST) && $_SERVER [‘REQUEST_METHOD’] == ‘POST’) { $data = // processing codes here unset $data; }
How do you stop a form from being submitted twice?
Returning “false” from the submit handler will prevent the form from submitting.
How do I stop a page from submitting?
The simplest solution to prevent the form submission is to return false on submit event handler defined using the onsubmit property in the HTML
from the section I wanted to prevent from posting and refreshing. Here only Buttons submit as they should.