I'm using the jQuery UI Autocomplete with a local datasource (source: myArray
). I want the autocomplete to propose only the results that start with the string entered instead of the default case-insensitive contains search. Is there a simple solution for this or do I have to provide my custom search/source callback?
JQuery UI Autocomplete use startsWith
autocompletejqueryjquery-ui
Related Topic
- Javascript – Add table row in jQuery
- Javascript – How to check if an element is hidden in jQuery
- Javascript – Setting “checked” for a checkbox with jQuery
- Javascript – How to know which radio button is selected via jQuery
- Javascript – How to check whether a checkbox is checked in jQuery
- Javascript – How to refresh a page with jQuery
- Javascript – Scroll to an element with jQuery
Best Answer
See this:
Match start word:
http://blog.miroslavpopovic.com/jqueryui-autocomplete-filter-words-starting-with-term
He overrides the autocomplete filter method. I use this and it works well.
Match word:
Match startsWith of any word in the string.
e.g. "LHR london" is matched by "london"
\b assert position at a word boundary (^\w|\w$|\W\w|\w\W)