You are here: Reference > JavaScript > client-side > event handling > events > onreset

onreset event | reset event

Browser support:
Occurs on a form before it is reset.
When a form is reset, all controls within the form are set to their initial values.
The onreset event is cancelable, if it is canceled, the reset operation is not performed.

How to register:

<ELEMENT onreset="handler">

In JavaScript:
object.onreset = handler;
object.addEventListener ("reset", handler, useCapture);
object.attachEvent ("onreset", handler);
You can find the related objects in the Supported by objects section below.
The event object is accessible to all event handlers in all browsers. The properties of the event object contain additional information about the current event. To get further details about these properties and the possible event handler registration methods, please see the page for the event object.
For a complete list of events, see the page for Events in JavaScript.

Basic information:

Bubbles No
Cancelable Yes
Event object Event

Actions that invoke the onreset event:

Example HTML code 1:

This example illustrates the use of the onreset event:
    <script type="text/javascript">
        function OnReset () {
            var textField = document.getElementById ("myText");
            alert ("The value of the text field before the reset operation:\n" + textField.value);
    <form onreset="OnReset ()">
        <input type="text" id="myText" size="50" value="Modify this text first, then click on the reset button!" />
        <input type="reset" />
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content