addEventListener("reset", myFunction); - Javascript DOM Event

Javascript examples for DOM Event:addEventListener

Description

The onreset event occurs when a form is reset.

Summary

Bubbles Yes
Cancelable Yes
Supported HTML tags: <form>

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<form id="myForm">
  Enter name: <input type="text">
  <input type="reset">
</form>//  w w w  .  j  a  v a  2s  .c  om

<p id="demo"></p>

<script>
document.getElementById("myForm").addEventListener("reset", myFunction);

function myFunction() {
    document.getElementById("demo").innerHTML = "The form was reset";
}
</script>

</body>
</html>

Related Tutorials