Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery autocomplete wildcard

I am using the jquery.ui.autocomplete plugin, but I noticed when it searches, it uses a wild-card like this '%value%'.

I am using the auto-complete for zip-codes, and I think it would make more sense of the wild-card worked like this 'value%' so when you start typing it only filters out the items that 'start with' what you already typed.

I can't find any documentation on this though.

Anyone have any experience with this?

Much appreciated.

like image 405
Nealv Avatar asked May 25 '26 02:05

Nealv


1 Answers

You can use a function as the source option for the autocomplete plugin which should allow you to get the behaviour you want.

There's a very similar question asked here: jQuery UI Autocomplete widget search configuration which has an excellent answer and working example.

like image 181
KevD Avatar answered May 26 '26 14:05

KevD