What is the event to catch form submission in Javascript?
问题 A couple of questions here: I was wondering what event do I use to execute some javascript on form submission (to do some validation)? Once I have done my validation, how do I then submit the form in javascript ? Cheers... 回答1: Let's say you have a form named myForm : var form = document.getElementById('myForm'); To catch submission: try { form.addEventListener("submit", someFunction, false); } catch(e) { form.attachEvent("onsubmit", someFunction); //Internet Explorer 8- } Note: If you want