0
I have the following div that this hidden:
<div class="card" id="cnpj_erro" style="visibility:hidden">
<div class="body">
<div class="header bg-red">
<h2>
CNPJ inválido <small>Confira os números</small>
</h2>
</div>
</div>
</div>
And the function:
<script>
function verificarValidacaoCNPJ() {
debugger;
var valCNPJ = !document.getElementById("txCNPJ_cad_emp") ? "" : document.getElementById("txCNPJ_cad_emp").value;
if (!validarCNPJ(valCNPJ)) {
document.getElementById('cnpj_erro').setAttribute('style', 'visibility:visible');
}
else {
document.getElementById('cnpj_erro').setAttribute('style', 'visibility:hidden');
}
}
</script>
It is validating right, no problem, but I am not able to change the attribute 'style', 'visibility' so that it is displayed or hidden.
Debugging when it enters the option document.getElementById('cnpj_erro').setAttribute('style', 'visibility:visible');
returns Return value: undefined
Have you tried using
document.getElementById('cnpj_erro').style.visibility = "visible"
?– Woss
was the first one I tried, also tried
document.getElementById('cnpj_erro').visibility = "visible"
– Gleyson Silva