The onreset
property of the GlobalEventHandlers
mixin is an event handler that processes reset
events.
The reset
event fires when the user clicks a reset button in a form (<input type="reset">
).
The onreset
property of the GlobalEventHandlers
mixin is an event handler that processes reset
events.
The reset
event fires when the user clicks a reset button in a form (<input type="reset">
).
target.onreset = functionRef;
functionRef
is a function name or a function expression. The function receives an Event
object as its sole argument.
This example logs the current Event.timeStamp
whenever you reset the form.
<form id="form"> <label>Test field: <input type="text"></label> <br><br> <button type="reset">Reset form</button> </form> <p id="log"></p>
function logReset(event) { log.textContent = `Form reset! Time stamp: ${event.timeStamp}`; } const form = document.getElementById('form'); const log = document.getElementById('log'); form.onreset = logReset;
Specification |
---|
HTML Standard # handler-onreset |
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
onreset |
1 |
12 |
9 |
9 |
≤12.1 |
1 |
1 |
18 |
9 |
≤12.1 |
1 |
1.0 |
© 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/GlobalEventHandlers/onreset