// Validate your form using the jQuery onsubmit function... It'll really work...
$(document).ready(function(){$(#form).submit(e){e.preventDefault();if(validation())document.form1.submit();});});
function validation(){// Your form checking goes here.}
<form id='form1' method='POST' action=''>// Your form data</form>
<form action="..."><!-- insert this next line immediately after the <form> opening tag --><button type=submit onclick="return false;" style="display:none;"></button>
<!-- everything else follows as normal --><!-- ... --><button type=submit>Submit</button></form>
window.addEventListener('keydown', function(event) {//set default value for variable that will hold the status of keypresspressedEnter = false;
//if user pressed enter, set the variable to trueif (event.keyCode == 13)pressedEnter = true;
//we want forms to disable submit for a tenth of a second onlysetTimeout(function() {pressedEnter = false;}, 100)
})
//find all formsvar forms = document.getElementsByTagName('form')
//loop through formsfor (i = 0; i < forms.length; i++) {//listen to submit eventforms[i].addEventListener('submit', function(e) {//if user just pressed enter, stop the submit eventif (pressedEnter == true) {updateLog('Form prevented from submit.')e.preventDefault();return false;}
updateLog('Form submitted.')})}
var log = document.getElementById('log')updateLog = function(msg) {log.innerText = msg}
<form><p>Sample textarea (try enter key):</p><textarea rows="4">Hit enter, a new line will be added. But the form won't submit</textarea><br/><p>Sample textfield (try enter key):</p><input type="text" placeholder="" /><br/><input type="submit" value="Save" /><h3 id="log"></h3></form>