Horje

How to add a JavaScript when the Reset button in a form is clicked

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 add a JavaScript when the Reset button in a form is clicked




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