I have a select
disabled and I want if you try to click or hover over it, display a message to notify the reason why it is disabled, but apparently the events do not work with disabled elements, so I don't know if there is a way to do what I say, I already have the method, it's just making it work with an event. I leave the HTML
and the method inJavaScript
HTML
of the select
<div class="form-group row ml-1 justify-content-center">
<label for="empleado" class="col-form-label">Empleado:</label>
<div class='col-sm-4 mr-3'>
<select type="text" class="custom-select" onmouseover="empleadoIsEmpty()" id="empleado" name="empleado" disabled="disabled">
<option value="0">Seleccionar empleado</option>
<?php
for ($i=0; $i < count($empleados); $i++) {
echo "<option value='{$empleados[$i]['id_empleado']}'>{$empleados[$i]['nombres']} {$empleados[$i]['apellidos']}</option>";
}
?>
</select>
</div>
JS
function empleadoIsEmpty(){
empleado = document.forms["formRegistro"]["empleado"];
if(empleado.disabled){
msg = "<ul>";
msg += "<li> Debes seleccionar fecha y sede para habilitar los empleados </li>"
msg += "</ul>";
document.getElementById("errores").innerHTML = msg;
}else{
console.log("no entré");
}
}
Thanks in advance.