In JavaScript, using the addEventListener()
method:
object.addEventListener("reset",
myScript);
This example uses the addEventListener()
method to attach a "reset" event to a form element.
When you reset the form, a function is triggered which outputs some text.
<!DOCTYPE html> <html> <body> <form id="myForm"> Enter name: <input type="text"> <input type="reset"> </form>/*from ww w . j av a 2 s . 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>
Bubbles: | Yes |
---|---|
Cancelable: | Yes |
Event type: | Event |
Supported HTML tags: | <form> |