What is the usage of onreset event in JavaScript?


The onreset event is useful when a form is reset. You can try to run the following code to learn how to implement onreset event in JavaScript −

Example

<!DOCTYPE html>
<html>
   <body>
      <script>
         function resetFunct() {
            alert("The form was reset");
         }
      </script>
      <form onreset = "resetFunct()">
         Enter age: <input type = "number"><br>
         Enter birth month: <input type = "text"><br>
         <input type = "reset">
      </form>
   </body>
</html>

Updated on: 23-Jun-2020

230 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements