Perform function on form submit
Posted
by flight643
on Stack Overflow
See other posts from Stack Overflow
or by flight643
Published on 2010-06-15T15:58:44Z
Indexed on
2010/06/15
16:12 UTC
Read the original article
Hit count: 179
Hopefully this is a pretty simple question! I've got the code working in jQuery to listen for a specific form on a page to be submitted and perform an alert when it is.. I.e.: The form itself doesn't have a name so I am targetting the form within a specific form ID.
$("#content form").submit(function() {
alert("lorem ipsum dolor?");
});
What would be the syntax for performing this in javascript alone without using jquery? For example, I have this code (below) and just am unsure of how to listen for the form to be submitted to perform an action..
var submitform = document.getElementById("content").getElementsByTagName("form");
Thanks!
© Stack Overflow or respective owner