I use this jQuery Autocomplete - framework for an input field (after input of three characters the suggestions appear), and I only will allow entries of autocomplete suggestion.
My first approach was:
var nameSelectedOverSearch = false;
var availablePersons = [];
$(function() {
$("#anspr").autocomplete({
source: availablePersons,
select: function(event, ui) {
nameSelectedOverSearch = true;
}
});
});
the user must click an autocomplete suggestion but it is still possible that afterwards the user change the input. Is there any possibility to only allow autocomplete inputs?
You can use this awesome library https://harvesthq.github.io/chosen/. I did a full exemple with autocomplete and chosen to compare : https://jsfiddle.net/Tintin37/uw52snsq/
I think it fits exactly your needs.
Relevant code :