Pak RT’s 17 August sign-up form with a <datalist>: the browser answers which list input.list found, what becomes of an off-list value, and what Kirim checks…
Why it matters
Suggesting cities, tags, products, email domains: everyday form needs. <datalist> solves the simple cases for free: keyboard, screen reader (role=combobox) and filtering are the browser’s job. Many dirty-data bugs come from assuming "the value is surely one of the options".
The key idea
A datalist is a suggestion, not an allow list
Common mistakes
Assuming the value is surely one of the <option>s A datalist enforces nothing: people may type another value and still send it. Add pattern (matching the whole value) + required for convenience, and always check again on the server.
Using <option>Text</option> instead of a value attribute That is actually fine: without a value attribute, option.value = its text. The surprise is the other way round: <option value="JB">Jawa Barat</option> fills the field with JB and sends JB; "Jawa Barat" is only a label that is searched too.
Wiring list to the wrong thing The list attribute must equal the <datalist>’s id exactly (not its name). A typo raises no error: input.list becomes null and the dropdown quietly disappears.
Try it in this playground
Type "ban" into the Kota asal field The browser filters its suggestions itself: Bandung is left. You wrote no filtering code at all.
Type a city that is not listed (e.g. "Bali"), then Send It is still sent: the neighbourhood head receives it. A datalist refuses nothing.
Open Code + name, pick Jawa Barat, then Send The field holds JB and the neighbourhood head receives JB: the value is sent, the label only helps searching.
Open required + pattern, then Send with "Bali" Now the browser refuses with its own message. The difference is pattern + required, not the datalist.