Prevent form submission with enter key

You can mimic the tab key press instead of enter on the inputs like this:

//Press Enter in INPUT moves cursor to next INPUT
$('#form').find('.input').keypress(function(e){
    if ( e.which == 13 ) // Enter key = keycode 13
    {
        $(this).next().focus();  //Use whatever selector necessary to focus the 'next' input
        return false;
    }
});

You will obviously need to figure out what selector(s) are necessary to focus on the next input when Enter is pressed.


Note that single input forms always get submitted when the enter key is pressed. The only way to prevent this from happening is this:

<form action="/search.php" method="get">
<input type="text" name="keyword" />
<input type="text" style="display: none;" />
</form>