After the onsubmit event has fired and the form has been submitted (via an action="mailto:[email protected]") , is there a way to then clear the form, close the window or what? Is there a post submit that I can hook into via JavaScript. This must be a client side only solution.
Form reset() Method The reset() method resets the values of all elements in a form (same as clicking the Reset button). Tip: Use the submit() method to submit the form.
To clear an input field after submitting:Add a click event listener to a button. When the button is clicked, set the input field's value to an empty string. Setting the field's value to an empty string resets the input.
The <input type="reset"> defines a reset button which resets all form values to its initial values.
A quick and easy solution:
<form action="mailto:[email protected]"
onsubmit="this.submit(); this.reset(); return false;">
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With