I recently migrated a few of my Autocomplete plugins from the one produced by bassistance to the jQuery UI autocomplete.
How can the \"mustMatch\" and \"selectFirst\
I found this question to be useful.
I thought I'd post up the code I'm now using (adapted from Esteban Feldman's answer).
I've added my own mustMatch option, and a CSS class to highlight the issue before resetting the textbox value.
change: function (event, ui) {
if (options.mustMatch) {
var found = $('.ui-autocomplete li').text().search($(this).val());
if (found < 0) {
$(this).addClass('ui-autocomplete-nomatch').val('');
$(this).delay(1500).removeClass('ui-autocomplete-nomatch', 500);
}
}
}
CSS
.ui-autocomplete-nomatch { background: white url('../Images/AutocompleteError.gif') right center no-repeat; }