Good evening guys, I have the following code in a hotel system that I'm putting together:
<?php
include "Hospede.php";
$newHospede = new Hospede();
$rs = $newHospede->listarNomesHospedes();
$qtdHospedes = mysql_num_rows ($rs);
?>
<input list="hospedes" name="hospede" id="hospede" required>
<datalist id="hospedes">
<?php
for ($cont = 0; $cont < $qtdHospedes; $cont++){
$nome = mysql_result ($rs, $cont, "nome");
?>
<option value="<?php echo $nome; ?>">
<?php
}
?>
</datalist>
The guest field has a list of the guest names that the query in the database returned, but I'm having a problem: Because the datalist field allows the user to type to fetch an item from the list, it is it is possible for the user to type anything and submit the form, since the "required" attribute of the HTML leaves only the fact that the user has typed something inside the field. I need to find a way to force the user to select an item from the list. If you can help, thank you.