mardi 19 septembre 2017

How to count items in HTML name array attribute?

I have 3 checkboxes and the user can only select 1 or 2 of them. If the user select 3 checkbox, I will show a message with jQuery saying "You can't select 3 items".

<input type="checkbox" value="Walk" name="sports[]">
<input type="checkbox" value="Swim" name="sports[]">
<input type="checkbox" value="Run"  name="sports[]">

Is it possible to count items that are inside sports[] array?

Aucun commentaire:

Enregistrer un commentaire