Required textarea when checkbox is marked

Hi, Im working on my survey form project and Im trying to make a textarea next to my checkbox, which is required to be filled in when the checkbox is marked. I have created to inputs in a label like this:

    <label><input type="checkbox" class="inline"/> Other: <input type="textarea" name="feature" class="inline" /></label> 

There is no textarea type for the input tag. Use the textarea tag instead:


If you are interested in why textarea is a separate tag: html - Why isn't textarea an input[type="textarea"]? - Stack Overflow

Thanks, but the same question applies with the tag “text”?

<input  type="radio" class="inline" /> Other:  <input type="text" class="inline" /> </label> 

Yep, that’s fine. To make both the text input and textarea required, simply add it inside the tag:

<input type="text" class="inline" required/>
<textarea required></textarea>

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.