1
<label>Itinerário</label>
<select id="itinerario" name="itinerario" class="form-control form-control-sm" required readonly>
<option value="" selected>Selecione um itinerário</option>
</select>
JS:
if($('#itinerario :selected').text() == ""){
alert('Elemento vazio!');
}
I am trying to make the above code but it does not recognize the value, I need that when it is selected at that value="" empty, appear the Alert.
And when that
if
is executed?– Woss
When loading the page it already valid.
– KevinF
Are you using jQuery? If yes, it would be cool if you [Edit] the question and add the tag [tag:jquery].
– fernandosavio