Nuestros voluntarios aún no han traducido este artículo al Español. ¡Únete a nosotros y ayúdanos a traducirlo!
También puedes leer el artículo en English (US).

The reset event fires when a <form> is reset.

General info

Interface Event
Bubbles Yes (although specified as a simple event that doesn't bubble)
Cancelable Yes
Targets Element
Default Action Reset the value of all elements of the parent form.

Properties

Property Type Description
target Read only EventTarget The event target (the topmost target in the DOM tree).
type Read only DOMString The type of event.
bubbles Read only Boolean Whether the event normally bubbles or not.
cancelable Read only Boolean Whether the event is cancellable or not.

Example

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 Status Comment
HTML Living Standard
The definition of 'reset' in that specification.
Working Draft No change
HTML 5.2
The definition of 'reset' in that specification.
Recommendation No change
HTML 5.1
The definition of 'reset' in that specification.
Recommendation Added info that the event is not trusted.
HTML5
The definition of 'reset' in that specification.
Recommendation Initial definition

See also

Etiquetas y colaboradores del documento

Etiquetas: 
Última actualización por: mfluehr,