HTMLFormElement: reset event

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 Standard
# event-reset

Browser compatibility

BCD tables only load in the browser

See also