Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery Autocomplete field

I'm using jQuery's autocomplete feature. The user enters a college name, and autocomplete feature shows the list of similar colleges that he/she entered. It works fine. The only problem is that I want to disable the user from entering any other college apart from those that are shown in the drop-down autocomplete menu. I mean, I want to make the user choose, from the available list, he/she cannot enter any other text in the field. He will enter some text, for which autocomplete will display the results, and then choose from that list. Currently, the user is able to enter a search string, choose from the results and then modify the field. I don't want that.

How can I do that? Currently, the relevant html is:

<div class="ui-widget txt-fld">
   <label class="labelname">College:</label>
   <input id="college" class="textinput" name="college" />
</div>
like image 244
xan Avatar asked Dec 21 '25 01:12

xan


1 Answers

I know one universal select which helped me over and over again. Look at this:

http://ivaynberg.github.com/select2/

maybe it helps you.

like image 200
winzo Avatar answered Dec 22 '25 17:12

winzo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!