views:

266

answers:

3

I'm using JQuery Autocomplete (bassistance) and have run into a problem. If the mouse rolls over one of the autocomplete suggestions and the user hits the return key (rather than clicking to make selection), the form is submitted and goes to whatever link was rolled over at the time.

This is a problem as people click in the textbox, and when typing their search, leave the pointer where the autocomplete popup appears. So when they hit enter, it doesn't do the search for whatever they typed in the box but whatever was highlighted in the autocomplete suggestions.

Is there a way to stop this?

Using Google as the functionality I'm after...

So just to clarify - I want selections via mouse and keyboard to go to the same place, but if the UP or DOWN arrow has not been pressed (user not selected an autocomplete option via the keyword), dont go to the URL specified in the autosuggest - instead submit the form (traditional method without JQuery) based on what has been typed in the textbox.

I hope I'm explaining this clearly? :S

A: 

Or perhaps there is an alternative with this function built in?

ILT
A: 

There is a code block in the autocomplete.js file that handles KEY.RETURN. I just commented out that line. Users can still use KEY.TAB to make a selection from the autocomplete.

brian
A: 

Thanks Brian :)