HTMLFormElement: reset event
The reset
event fires when a <form>
is reset.
Bubbles | Yes (although specified as a simple event that doesn't bubble) |
---|---|
Cancelable | Yes |
Interface | Event |
Event handler property | GlobalEventHandlers.onreset |
Examples
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>
JavaScript
function logReset(event) { log.textContent = `Form reset! Time stamp: ${event.timeStamp}`; } const form = document.getElementById('form'); const log = document.getElementById('log'); form.addEventListener('reset', logReset);
Result
Specifications
Specification |
---|
HTML Standard (HTML) # event-reset |
Browser compatibility
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 |
Yes |
12 |
Yes |
Yes |
Yes |
Yes |
Yes |
Yes |
Yes |
Yes |
Yes |
Yes |
See also
- HTML
<form>
element
© 2005–2021 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