HTML onreset Attribute

HTML onreset Attribute: The HTML onreset Attribute is defined as it fires when a form is reset. The onreset attribute is part of the Event attributes and can be used on the <form> element.

HTML onreset Attribute

The HTML onreset attribute can be applied to the <form> element.

Syntax: <element onreset=”script”>

Browser Support:

The HTML onreset attribute is supported by the following browsers:

  • Chrome
  • Firefox
  • Safari
  • Opera
  • Internet Explorer

Example: for <form> element

<!DOCTYPE html>
<html>
<body>
<form onreset="myFunction()">
  Enter name: <input type="text">
  <input type="reset">
</form>
<script>
function myFunction() {
  alert("The form was reset");
}
</script>

</body>
</html>

Output:

HTML onreset attribute