16Jul/103
Using Jquery to disable the enter key
There are times that you do not want a form to automatically submit when a user hits the enter key. Or if you want to do some validation via javascript before you allow the submit to go through.
//Bind this keypress function to all of the input tags $("input").keypress(function (evt) { //Deterime where our character code is coming from within the event var charCode = evt.charCode || evt.keyCode; if (charCode == 13) { //Enter key's keycode return false; } });
By returning false in the keypress function it tells the browser not to allow the enter key event.
August 30th, 2011 - 07:29
Just what I was looking for. Thank you!
February 1st, 2012 - 08:13
Thanks, that was driving me nuts trying to solve.
February 8th, 2012 - 12:37
Thank you, i searching for a long time for this.