Hi everyone, I am working on the Survey Form certification project and I was curious if there is a way to make a text input required only if a specific radio button is selected. I know this is not part of the challenge but I am just curious. Many times a radio button labeled as “Other” has a text box to enter what that other item is. I want to make this text box required only if this button is selected.
I tried nesting the text input within the associated radio button and added the required attribute to the text field. But this just makes it required regardless of the radio button selected.
<label><input type="radio" value="other" name="offense-defense" class="inline" /> Other<label>If other please specify: <input type="text" name="other" placeholder="e.g. goalkeeping, pitching, etc." required /></label></label>