CKTIS / JavaScript
HTMLFormElement.reset() — restoring a form's default state
HTMLFormElement.reset() restores the default state of controls associated with a form rather than simply emptying them. It first dispatches a cancelable reset event; preventDefault() stops the restoration.
Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
Syntax
form.reset()HTMLFormElement.reset is a browser DOM API method, not part of ECMAScript itself. Calling form.reset() takes no arguments and returns undefined. All current major browser engines support it; a Node.js version alone does not establish availability of this API.
Reset affects resettable controls whose form owner is the target form, not just its descendants. For a text input, it restores the default value; for a checkbox, it restores the default checked state. It therefore does not mean “empty everything.” Changing defaultValue changes the value used by a subsequent reset; it is not an immutable snapshot of the state at page load. Reset does not remove the disabled attribute.
Before changing controls, the form dispatches a bubbling, cancelable reset event. Calling event.preventDefault() in its handler stops the reset. Reading values in a synchronous handler for this event happens before restoration. Changes performed by reset do not fire input events.
Avoid controls with name="reset" or id="reset": they can shadow the method, making form.reset() no longer callable. If that collision occurs, use HTMLFormElement.prototype.reset.call(form). The example demonstrates both a normal reset and its cancellation.
Examples
const form = document.createElement('form');
const input = document.createElement('input');
input.defaultValue = 'Ada';
form.append(input);
input.value = 'Grace';
form.addEventListener('reset', () => {
console.log('before reset: ' + input.value);
});
form.reset();
console.log('after reset: ' + input.value);
input.value = 'Lin';
form.addEventListener('reset', event => event.preventDefault(), { once: true });
form.reset();
console.log('after canceled reset: ' + input.value);Result
before reset: Grace after reset: Ada before reset: Lin after canceled reset: Lin
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.