Reputation: 5566
I use the following code to provide a multiple choice in an HTML form:
Estado: <input list="states"><datalist id="states">
<option value="Pendiente">Pendiente</option>
<option value="Frenada">Frenada</option>
<option value="Finalizada">Finalizada</option>
</datalist><br>
The thing is, I can still type in the resulting input box in the browser. I want to block the user from typing, so that it's only choice is to select from the list. Is this possible?
Upvotes: 3
Views: 9023
Reputation: 1136
If you don't want to let the user type in the input box, then don't use <input>
;
use <select></select>
instead
Estado:
<select name="states">
<option value="Pendiente">Pendiente</option>
<option value="Frenada">Frenada</option>
<option value="Finalizada">Finalizada</option>
</select><br>
Upvotes: 3
Reputation: 10675
Use this to prevent user from typing and make a choice from available options.
<select name="states">
<option name="Pendiente">Pendiente</option>
<option name="Frenada">Frenada</option>
<option name="Finalizada">Finalizada</option>
</select>
Upvotes: 4