I'm using jQuery 1.4.4 and jQuery UI 1.8.9. I have an autocomplete field that works really well, however I'd like to contrain the input to only what the autocomplete backend comes up with.
The documetation states:
mustMatch Boolean Default: false
If set to true, the autocompleter will
only allow results that are presented
by the backend. Note that illegal
values result in an empty input box.
$( ".client" ).autocomplete({
minLength: 2,
mustMatch: true,
source: function( request, response ) {
var term = request.term;
if ( term in client_cache ) {
response( client_cache[ term ] );
return;
}
client_lastXhr = $.getJSON( "amex/start.php?action=autocomplete&field=client", request, function( data, status, xhr ) {
client_cache[ term ] = data;
if ( xhr === client_lastXhr ) {
response( data );
}
});
}
});
You probably found this option on the documentation page for the deprecated plugin. jQueryUI's current documentation is located here.
It looks like they removed the mustMatch
option, but according to this StackOverflow question, you can implement it yourself.