DEV Community

Discussion on: Autocomplete Dropdown using native HTML

Collapse
danielperna84 profile image
Daniel Perna

One problem - at least depending on the use case - with this is, that it allows to send other values than those specified in the list. F.ex. imagine a UI to configure the listening IP for a daemon where the available options would be populated by the IPs available on the host. With a regular select the user can only choose valid options, whereas the datalist-solution allows him to enter and submit a custom value, which could be invalid. Obviously the server side should handle such cases. But I still think this is important to know.

Collapse
tfisicaro profile image
Tim Fisicaro

When using a regular dropdown you can still change the option values and submit. Therefore you should always validate server side.

Collapse
brteller profile image
Brandon Teller

Yes, but that's missing the point. Even if you validate server side, having someone being able to submit a freeform text field defeats the purpose of a drop down which is to select pre determined values with text fields. Sure, you don't want bogus data going into the server, but ensuring the data is formatted before the server check is almost always necessary on the front end as well.