Enter name: ``` --- ##"> Enter name: ``` --- ##" />
Easy Tutorial
❮ Jsref Sqrt Prop Canvas Fillstyle ❯

onreset Event

Event Object

Example

Execute JavaScript when a form is reset:

<form onreset="myFunction()"> Enter name: <input type="text"> 
    <input type="reset"></form>

Definition and Usage

The onreset event is triggered after a form is reset.


Browser Support

Event
onreset Yes Yes Yes Yes Yes

Syntax

In HTML:

In JavaScript:

In JavaScript, using the addEventListener() method:

Note: The addEventListener() method is not supported in Internet Explorer 8 and earlier versions.


Technical Details

Bubbles: Yes
Cancelable: Yes
--- ---
Event Type: Event
--- ---
Supported HTML Tags: <form>, <keygen>
--- ---

More Examples

Example

Display the content written in the text field before the form is reset:

var x = document.getElementById("myInput");alert("Before reset, the text content is: " + x.value);

Example

Use the reset() method of the HTML DOM Form Object to reset the form. After execution, the onreset event is triggered, and a prompt message is displayed.

// Reset all element values of the form with id="myForm"
function myResetFunction() {   
    document.getElementById("myForm").reset();
}
// Display a prompt message after the form is reset
function myAlertFunction() {   
    alert("Form has been reset");
}

Event Object

❮ Jsref Sqrt Prop Canvas Fillstyle ❯