Javascript examples for DOM Event:addEventListener
The onsubmit event occurs when a form is submitted.
Bubbles | Yes |
---|---|
Cancelable | Yes |
Supported HTML tags: | <form> |
<!DOCTYPE html> <html> <body> <form id="myForm" action="/action_page.php"> Enter name: <input type="text" name="fname"> <input type="submit" value="Submit"> </form>//w w w . j a va 2 s . co m <script> document.getElementById("myForm").addEventListener("submit", myFunction); function myFunction() { console.log("The form was submitted"); } </script> </body> </html>