On my website I have several input fields in a form. I want the user to be able to submit the form on any of the fields by hitting the enter key. However, this causes an issue because in Internet Explorer and Safari if the user types a few letters and an autocomplete dropdown opens and they use arrow keys and hit enter to do the autocomplete, the form will submit.
How can I change this behavior?
Also note that I have a custom function for “submitting”. It is not the default submit.
Here is my jQuery code:
$('.submitButton').click( submitContactForm );
$('.column input, .submitButton').keydown(function( e ){
if( e.keyCode == 13 ){// if 'enter' key
$('.submitButton').click();
}
});
I have decided to use the safeEnter jQuery plugin. Looks like it will solve this problem nicely.