Execute a script when a reset button in a form is clicked in HTML?

HTMLWeb DevelopmentFront End Technology

When a form is reset, the onreset attribute triggers. You can try to run the following code to implement onreset attribute −

Example

<!DOCTYPE html>
<html>
   <body>
      <form onreset = "display()">
         Student Name:<br>
         <input type = "text" name = "sname">
         <br>
         Student Subject:<br>
         <input type = "text" name = "ssubject">
         <br>
         <input type = "reset" value = "reset">
      </form>
      <script>
         function display() {
            alert("Form reset successfull!");
         }
      </script>
   </body>
</html>
raja
Published on 14-Mar-2018 07:18:31
Advertisements