Autocomplete – Slight Improvement?

I’ve managed to get autocomplete working for a textfield.

I have added <b> tags around the search enquiry text in the results, see example:

So if you start typing House (h then o) you’ll see a dropdown for the text field:

  • Houses on Neptune
  • Great horses
  • Happy Horace


The problem is, when I choose one of the autocomplete suggestions, it populates the field with my HTML (as expected). So the text field will show Great <b>ho</b>rses if I select that autocomplete suggestion rather than Great horses

I’m trying to work out how to embolden the autocomplete suggestions (as above) but get Drupal to only put the plaintext version of the result the user chooses, into the text field.

So for example, the field gets populated with ‘4 Bedroom House’ but I want ‘4 Bedroom House’ to be entered.

Is this possible? Or should this be a feature request for the core?


Drupal version: