Clear form field after select for jQuery UI Autocomplete

Add $(this).val(''); return false;
to the end of your select function to clear the field and cancel the event 🙂

This will prevent the value from being updated. You can see how it works around line 109 here.

The code in there checks for false specifically:

if ( false !== self._trigger( "select", event, { item: item } ) ) {
  self.element.val( item.value );
}

Leave a Comment

File not found.