HTML DOM onreset Event
Last Updated :
15 Jun, 2023
The onreset event in HTML DOM occurs when a form is reset. Only the <form> tag is supported in this event.
Supported Tags
Syntax:
<element onreset="myScript">
object.onreset = function(){myScript};
- In JavaScript, using the addEventListener() method:
object.addEventListener("reset", myScript);
Example: Using the addEventListener() method
HTML
<!DOCTYPE html>
< html >
< head >
< title >
HTML DOM onreset Event
</ title >
</ head >
< body >
< h1 style = "color:green" >
GeeksforGeeks
</ h1 >
< h2 >HTML DOM onreset Event</ h2 >
< form id = "formID" >
Email:
< input type = "email" >
< input type = "submit" value = "Submit" >
< input type = "reset" >
</ form >
< script >
document.getElementById(
"formID").addEventListener("reset", GFGfun);
function GFGfun() {
alert("Form reset");
}
</ script >
</ body >
</ html >
|
Output:
Supported Browsers: The browsers supported by HTML DOM onreset Event are listed below:
- Google Chrome
- Internet Explorer
- Firefox
- Apple Safari
- Opera
Share your thoughts in the comments
Please Login to comment...