Use Submit Event Listener When Form Is Submitted Via Inline Javascript?
We have a script that tracks form submits by adding an event listener to the form. The problem is that one customer submits the form via a link using );
form[0].addEventListener("submit", function(e) {
e.preventDefault();
alert('event');
});
form[0].childNodes[3].addEventListener("click", function(e) {
e.preventDefault();
alert('event');
});
Solution 2:
instead of using the href try this
<form method="post" name="formname"class="form">
<inputtype="text"name="hello"><aonclick="javascript:document.formname.submit();">Submit</a><inputtype="submit"></form>
remove the href
and replace it with onclick
Solution 3:
try the following with jquery:
$("form").submit(function (e) {
e.preventDefault();
alert('event');
});
Reference here.
Post a Comment for "Use Submit Event Listener When Form Is Submitted Via Inline Javascript?"