The onreset property of the GlobalEventHandlers mixin is an EventHandler that processes reset events.
The reset event fires when the user clicks a reset button in a form (<input type="reset">).
Syntax
target.onreset = functionRef;
Value
functionRef is a function name or a function expression. The function receives an Event object as its sole argument.
Example
This example logs the current Event.timeStamp whenever you reset the form.
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.onreset = logReset;
Result
Specification
| Specification | Status | Comment |
| HTML Living StandardThe definition of 'onreset' in that specification. | Living Standard |
Browser compatibility
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.
Update compatibility data on GitHub
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
onreset
|
Chrome
Full support Yes |
Edge
Full support ≤18 |
Firefox
Full support Yes |
IE
? |
Opera
Full support Yes |
Safari
Full support Yes |
WebView Android
Full support Yes |
Chrome Android
Full support Yes |
Firefox Android
Full support Yes |
Opera Android
Full support Yes |
Safari iOS
Full support Yes |
Samsung Internet Android
Full support Yes |
Legend
- Full support
- Full support
- Compatibility unknown
- Compatibility unknown
See also
resetevent- HTML
<form>element
GlobalEventHandlers.onreset by Mozilla Contributors is licensed under CC-BY-SA 2.5.