Javascript DOM onreset Event via HTML Tag onreset attribute

Introduction

This example demonstrates how to assign an "onreset" event to a form element.

When you reset the form, a function is triggered which outputs 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.  j  a va 2  s . c o  m*/

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

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

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



PreviousNext

Related