I have a simple input field
and after entering I want to send it (the form in which it is located). I use jQuery, but not any autocompletion extension, so this is just the default browser:
$('#searchfield') .keypress(function(event) { var keycode; if (window.event) keycode = window.event.keyCode; else if (event) keycode = event.which; else return true; if (keycode == 13) $('#searchForm').submit(); });
The problem with this solution: When someone (in FF3) starts typing (say, "stackov"), then the down arrow goes for the proposed choice and gets there, the form submits, although it looks for "stackov" and not for the selected "stackoverflow "
As an alternative, I tried
$('#searchfield') .change( function() { $('#singleSearch').trigger('click'); })
This led me to the correct set of "stackoverflow", but now any departure from the field (as in blur (), after pressing some letters, for example) unwittingly sent it.
Any (perfectly tested;) advice on this?
source share