Block autosubmit of form when pressing enter inside a text field
March 11th, 2012This little javascript can be used to block the sometimes unwanted autosubmit behaviour of a form when the user presses enter while the textfield is active. (JQuery required)
Usage: <input type=”text” class=”blockautosubmit” id=”email” />
1 2 3 4 5 | $('input.blockautosubmit').keypress(function(e) { if (e.keyCode == 44 || e.which == 44 || e.keyCode == 13 || e.which == 13) { return false; } }); |