jQuery UI Autocomplete matching

Andrew Maurer
Andrew Maurer used Ask the Experts™
on
I want to use the jquery UI autocomplete but it isn't working as I expected. If a user types the letter "a", the results come back with "a fox jumped" "some fox named a jumped" etc... basically anything that had an "a" in it. How do I fix this or is there an option for it?

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
leakim971Multitechnician
Top Expert 2014

Commented:
What is the source of data ? A database ? A javascript array ?

Author

Commented:
Sorry, yes a javascript array.
leakim971Multitechnician
Top Expert 2014

Commented:
what version are you using ? jquery-ui-1.8.2.custom.min.js ?
Multitechnician
Top Expert 2014
Commented:
open you jquery-uixxxxxxxx.js file, search for something like : autocomplete.escapeRegex

for the  jquery-ui-1.8.2.custom.min.js, replace : new RegExp(e.ui.autocomplete.escapeRegex(c), "i")
by : new RegExp("^"+e.ui.autocomplete.escapeRegex(c),"i")

Author

Commented:
Perfect! Thanks much! I dont know why they did it this way.. it should at least be an option. It would take them like two seconds to option it out.... gawl! tahha thanks again.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial