I have the following div that is 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's validating right, no problem, but I'm not able to change the 'style', 'visibility' attribute so it is displayed or hidden.
Debugging when it enters option document.getElementById('cnpj_erro').setAttribute('style', 'visibility:visible');
returns Return value: undefined