john.tazam free asked 5 years ago


I've added the MDB Autocomplete for the user to select a country. Is it possible to change the settings (or use an MDB alternative) to achieve the following:

1) I only want the answer to be selected from the list. Currently if the user types in anything (that's not on the list) then it will be retained.

2) Ideally when the user selects a country then I would also like the country code to be displayed either in the selection or another field/hidden variable. (This requirement is not so important but would be really useful)

I don't think this is an unusual request but I can't find a solution on the MDB website - sorry if I've missed it


Jakub Strebeyko staff answered 5 years ago


Hi there @john.tazan

Don't worry, feature requests and the questions about API are what this forum is for.

Autocomplete was created as an aiding functionality and as such does not support limiting user's "inputting potential" out-of-the-box. Seems that having the users be able to only choose from the data options is impossible without altering the autocomplete code (starts at line 29210 of version 4.7.0 mdb.js). Answers to some general implementation questions seem needed too, like "How not to have user input strings as an end result in a text-input field?" or "What if they mistype?" - should the entered content disappear on blur event unless it was picked from the autocomplete's menu? Or perhaps should it be considered a form validation concern?

Enriching autocomplete choice clicks with some kind of secondary data binding is unfortunately out of current API scope as well (but seems possible with a little bit of fiddling - making it work with data objects and emitting an event on option click, perhaps?).

Hope it's of any use.

Best Regards, Kuba



Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue

  • ForumUser: Free
  • Premium support: No
  • Technology: General Bootstrap questions
  • MDB Version: -
  • Device: PC
  • Browser: Chrome
  • OS: Windows
  • Provided sample code: No
  • Provided link: No