Is it possible to make a one checkbox in a set of "checkboxes" (like selecting the age) required in html ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Is it possible to make a one checkbox in a set of "checkboxes" (like selecting the age) required in html ?

Since I came across a required drop-down list, I was wondering if I can apply the same thing on "checkboxes" !

16th Apr 2018, 2:16 PM
Ahmad Zendehdell
Ahmad Zendehdell - avatar
5 Answers
16th Apr 2018, 2:46 PM
Zeke Williams
Zeke Williams - avatar
+ 6
Yes it's possble but we seldom hide a list of checkboxes in a single control as it's not really user-friendly as we need another tab to expand the selection. Generally, we use checkbox for less than 5 options and dropdown list in any other cases. 😉
16th Apr 2018, 2:37 PM
Zephyr Koo
Zephyr Koo - avatar
+ 3
Well let's say you want your clients select their gender, and you don't want them to submit the form without filling the gender option, in that case how can we make this field required ? i hope you understand what i mean.
16th Apr 2018, 2:42 PM
Ahmad Zendehdell
Ahmad Zendehdell - avatar
+ 2
<input type="checkbox" required> You can make one or any required, but you'll have to use JavaScript to make "AT LEAST" one out of all of them required.
16th Apr 2018, 2:41 PM
Zeke Williams
Zeke Williams - avatar
+ 2
oh i see! tnx a lot 😊
16th Apr 2018, 2:50 PM
Ahmad Zendehdell
Ahmad Zendehdell - avatar