Is there a way to make autocomplete options only accept a listed option - not "custom" inputs?

Title
Solution:
that is unfortunately not how autocomplete works because they only serve as suggestions. to do that, you would need to compare the inputted value on your end.
Jump to solution
3 Replies
Solution
Seren_Modz 21
Seren_Modz 212mo ago
that is unfortunately not how autocomplete works because they only serve as suggestions. to do that, you would need to compare the inputted value on your end.
Favna
Favna2mo ago
:this: you will need to do input validation yourself. For example for @Dragonite I first try to use the user input exactly, and if it yields no results I do a fuzzy search with that input, grab the first 20 results, and show a string select menu to the user. You can test this by using /pokemon and typing something then hitting enter before the autocomplete populates entries
Teixeira
TeixeiraOP2mo ago
I see, I was hoping there was an alternative to validating the input (which is what I've been doing - in my case each option's value is an object id related to a mongoDB document, so now I just make it check if the value is a valid ObjectId string) Thank you both

Did you find this page helpful?