Unable to modify the HTML, only with Javascript perform the following operation:
I have a SELECT with four possibilities:
<select name="tipo" id="tipo">
<option selected value="none">Elige uno...</option>
<option value="rock">Rock</option>
<option value="pop">Pop</option>
<option value="punk">Punk</option>
<option value="indie">Indie</option>
</select>
When submitting a form, you DO NOT have to allow me to send it if I choose the first option, by default, whose text is: "Choose one ...". How could that be controlled?
Code:
//Función que comprueba que no se elige la opción por defecto "Elige uno...".
function comprobarTipo(){
if (!document.getElementById("tipo").value=="none"){ //Para comparar con el texto sería: .text="Elige uno..."
var tipo = document.getElementById('tipo').value;
return true;
}else{
document.getElementById("errores").innerHTML="El campo TIPO debe elegir una opción.";
document.getElementById("tipo").focus();
return false;
}
}
Choose the option you choose to show me "The TYPE field should choose an option." in all options. What is the reason?