jQuery UI AutoComplete: Only allow selected valued from suggested list

You could also use this:

change: function(event,ui){
  $(this).val((ui.item ? ui.item.id : ""));
}

The only drawback I’ve seen to this is that even if the user enters the full value of an acceptable item, when they move focus from the textfield it will delete the value and they’ll have to do it again. The only way they’d be able to enter a value is by selecting it from the list.

Don’t know if that matters to you or not.

Leave a Comment