Disable form submission via Enter key on only _some fields

You can capture and cancel the enter keypress on those fields like this:

$('.noEnterSubmit').keypress(function(e){
    if ( e.which == 13 ) return false;
    //or...
    if ( e.which == 13 ) e.preventDefault();
});

Then on your inputs just give them a class="noEnterSubmit" 🙂

Looking ahead in case others find this later, in jQuery 1.4.3 (not out yet) you can shorten it to this:

$('.noEnterSubmit').bind('keypress', false);

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)