You can make an event, when entered age, if it is less than 18 the fields of Father and Mother change to required
HTML:
<input type="text" name="idade" id="idade" required>
<label for="idade">Idade</label>
<input type="text" name="mae" id="mae">
<label for="mae">Mãe</label>
<input type="text" name="pai" id="pai">
<label for="pai">Pai</label>
JS:
var campoIdade = document.getElementById('idade');
campoIdade.onchange = function() {
var idade = campoIdade.value;
if(idade < 18) {
document.getElementById('mae').required = true;
document.getElementById('pai').required = true;
} else {
document.getElementById('mae').required = false;
document.getElementById('pai').required = false;
}
}
Then every time the age is entered, the check is done, and the parents' property is changed to mandatory if it is under 18 years.
Running here: https://jsfiddle.net/Lejq5x3v/3/
I hope it helps
Yes, you can use javascript to display the fields only if the age is less than 18
– Julio Henrique
If you could post the form it would make it easier.
– Taylor Roos