-3
I am having this error in my code: "Uncaught Typeerror: Cannot read Property 'checked' of null", I searched for it in Google, tried the presented solutions but none worked.
cadastro-cuidador.js:
function HabilitarUpload() {
if (document.getElementById(declaracaoCuidador).checked) {
document.getElementById(inputCertificado).removeAttribute("hidden");
} else {
document.getElementById(inputCertificado).setAttribute("hidden", "true");
}
}
index.html:
<!DOCTYPE html>
<html lang="pt-br">
<head>
<title>Cuidadores</title>
<meta charset="UTF-8">
<script language="JavaScript" src="./js/cadastro-cuidador.js" defer></script>
</head>
<body>
<div class="input-cuidador">
<p>
<label class="container">Sou um cuidador
<input type="checkbox" id="declaracaoCuidador" onclick="HabilitarUpload()">
<span class="checkmark"></span>
</label>
</p>
<p id="pInputCertificado" hidden="true">Insira seu certificado (.pdf, .png ou .jpg)
<input type="file" name="img-certificado" id="inputCertificado"></p>
</div>
</body>
</html>
I tried to put the script at the end of the body, but it didn’t solve.