JSFiddle - React, Tailwind, and code Playground
HTML
<form
name="test"
method="GET"
action="#"
onsubmit="alert('I was prevented!');return false;"
>
<p>
stuff in here, but no input[type="submit"]s!!!<br/>
what ever will we do?
</p>
<input
type="button"
value="Click me"
onclick="submitForm(document.test)"
/>
</form>
JavaScript
window.submitForm = function(form) {
//get the form element's document to create the input control with
//(this way will work across windows in IE8)
var button = form.ownerDocument.createElement('input');
//make sure it can't be seen/disrupts layout (even momentarily)
button.style.display = 'none';
//make it such that it will invoke submit if clicked
button.type = 'submit';
//append it and click it
form.appendChild(button).click();
//if it was prevented, make sure we don't get a build up of buttons
form.removeChild(button);
};
function test() {
if (console)
console.log('even I was called');
}
if (addEventListener)
document.test.addEventListener('submit', test, false);
else
document.test.attachEvent('onsubmit', test);