The reset
event fires when a <form>
is reset.
The reset
event fires when a <form>
is reset.
Use the event name in methods like addEventListener()
, or set an event handler property.
js
addEventListener("reset", (event) => {}); onreset = (event) => {};
A generic Event
.
This example uses EventTarget.addEventListener()
to listen for form resets, and logs the current Event.timeStamp
whenever that occurs.
html
<form id="form"> <label>Test field: <input type="text" /></label> <br /><br /> <button type="reset">Reset form</button> </form> <p id="log"></p>
js
function logReset(event) { log.textContent = `Form reset! Timestamp: ${event.timeStamp}`; } const form = document.getElementById("form"); const log = document.getElementById("log"); form.addEventListener("reset", logReset);
Specification |
---|
HTML Standard # event-reset |
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
reset_event |
1 | 12 | 6 | 9 | ≤12.1 | 3 | ≤37 | 18 | 6 | ≤12.1 | 1 | 1.0 |
<form>
element
© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/reset_event