[jQuery] Browser autocomplete & posting forms.

[jQuery] Browser autocomplete & posting forms.


Hello
I kinda typed this text in already, but thread did not appear so im
writing it again. Hopefully somebody clears up duplicate threads.
        $(function(){
            $('input').keydown(function(e){
                if (e.keyCode == 13) {
                    $(this).parents('form').submit();
                    return false;
                }
            });
        });
This script handles it very well, but it has some problems. Specially
with browsers autocomplete. When i use this script and start typing in
a value into form, then it offers complete word. When i press key down
to choose it and press enter to select it, the form gets posted empty.
Which blows.
Is there a simple workaround to adapt with autocomplete or do i have
to start counting enters - if up or down key has been pressed then 1st
enter does nothing and 2nd posts the form?
Alan.