HTMLFormElement: reset event
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
The reset
event fires when a <form>
is reset.
Syntax
Use the event name in methods like addEventListener()
, or set an event handler property.
js
addEventListener("reset", (event) => {});
onreset = (event) => {};
Event type
A generic Event
.
Examples
This example uses EventTarget.addEventListener()
to listen for form resets, and logs the current Event.timeStamp
whenever that occurs.
HTML
html
<form id="form">
<label>Test field: <input type="text" /></label>
<br /><br />
<button type="reset">Reset form</button>
</form>
<p id="log"></p>
JavaScript
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);
Result
Specifications
Specification |
---|
HTML # event-reset |
Browser compatibility
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
reset event |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
See also
- HTML
<form>
element