JSFiddle - React, Tailwind, and code Playground
by rodrigorf
HTML
<input type="checkbox" name="idade" value="true" onclick="validar();"> Maior de 18 anos<br>
<div id="parents">
Nome Pai: <input id="txtPai" type="text" name="fname"><br>
Nome Mãe: <input id="txtMae" type="text" name="lname"><br>
<button>Enviar</button>
</div>
JavaScript
function validar() {
txtMae = document.getElementById("txtMae");
txtPai = document.getElementById("txtPai");
if (txtMae.disabled === true) {
txtMae.disabled = false;
} else {
txtMae.disabled = true;
}
if (txtPai.disabled === true) {
txtPai.disabled = false;
} else {
txtPai.disabled = true;
}
}