Horje

How to Execute a JavaScript when the Reset button in a form is clicked - HTML onreset Attribute

When you reset the form, a function is triggered which alerts some text.
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<p>When you reset the form, a function is triggered which alerts some text.</p>

<form onreset="myFunction()">
  Enter name: <input type="text">
  <input type="reset">
</form>

<script>
function myFunction() {
  alert("The form was reset");
}
</script>

</body>
</html>

Output should be:

How to Execute a JavaScript when the Reset button in a form is clicked - HTML onreset Attribute




Type:
html
Category:
Web Tutorial
Sub Category:
HTML Attribute
Uploaded by:
Admin