Reputation: 1510
I have an irritating problem with submitting form on pressing Enter key.
In my form Enter key is bound to javascript method that submits it (override is caused by using styled links instead of submit buttons). Now when user begins to write his username in one of the fields he gets browser suggestions for autofill. It's cool, but choosing one of them requires pressing Enter key, which submits the form before the choice.
Is there any way to detect the hint window of the browser?
The problem does not occur in chrome.
Upvotes: 1
Views: 355
Reputation: 20768
Add return false;
before the function call in your onkeydown
. I had a very similar problem not long back. E.g.
<input type="text" onkeydown="return event.keyCode!=13; someFunction()" />
Upvotes: 1