Open In App

HTML DOM onreset Event

Last Updated : 15 Jun, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

The onreset event in HTML DOM occurs when a form is reset. Only the <form> tag is supported in this event.

Supported Tags 

Syntax: 

  • In HTML: 
<element onreset="myScript">
  • In JavaScript: 
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

Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads