Javascript DOM onreset Event

Introduction

Execute a JavaScript when a form is reset:

When you reset the form, a function is triggered which alerts some text.

View in separate window

<!DOCTYPE html>
<html>
<body>
<form onreset="myFunction()">
  Enter name: <input type="text">
  <input type="reset">
</form>/*from  w w w .ja  v  a2 s  . c  om*/

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

</body>
</html>

The onreset event occurs when a form is reset.

Bubbles: Yes
Cancelable: Yes
Event type: Event
Supported HTML tags: <form>



PreviousNext

Related