I have prepared this demo for the problem http://jsfiddle.net/20k4ur8o/
As you can see when you try to submit the form via the input it is stopped but when you click the button the form submits. How can I prevent the form from submitting when .submit()
is called without overwriting the default behavior of the function, because I need to also keep other submit listeners active when it is called?
HTML
<form action=test id=form>
<input type=submit>
</form>
<button id=submit>Submit</button>
JS
document.getElementById('form').addEventListener('submit', function (e) {
e.preventDefault();
alert('stopped');
}, false);
document.getElementById('submit').onclick = function () {
document.getElementById('form').submit();
}