0
I have two radio inputs
<input id="tab-1" type="radio" value="juridica" name="tab" class="sign-in"><label for="tab-1"class="tab">Jurídico</label>
<input id="tab-2" type="radio" value="fisica" name="tab" class="sign-up" checked="checked"><label for="tab-2"class="tab">Físico</label>
and I want to make a check for which one is selected, by default the physical is already checked.
if ($("#tab-1").prop("checked")){
document.getElementById('cpf').required = true;
document.getElementById('nome-completo').required = true;
document.getElementById('cnpj').required = false;
document.getElementById('razao-social').required = false;
} else {
document.getElementById('cpf').required = false;
document.getElementById('nome-completo').required = false;
document.getElementById('cnpj').required = true;
document.getElementById('razao-social').required = true;
}
however, it is not working. When I select the legal does not work. It is only worked for the physical, which comes pre-selected.
try to do
$("#tab-1").is(":checked")
– Máttheus Spoo