Is it possible to insert the required attribute in the input field in some way only if a certain radio is checked?
I have an input field called "ladder-meters" that does not need to be filled by default. But if the user checks the switch called “stairs”, the field “stair meters” must be filled.
My input is as follows:
<input type="text" name="ladder-meters" id="ladder-meters">
and he should like it at the onchange event on the radio
<input type="text" name="ladder-meters" id="ladder-meters" required>
javascript html5 radio-button onchange required
Morten hagh
source share