Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Form Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Validate - Limit # of Checkboxes or Customize Name within Input

Go to End

2 Posts   1135 Views


Community Member, 191 Posts

22 August 2011 at 6:27pm

I'm trying jQuery Validate to limit the # of checkboxes a user can choose in my form (MultiForm module). To do that, the set of checkboxes need to have the same name=" " within the input.


<input name="tech" id="ebio" type="checkbox" value="" />
<input name="tech" id="mna"  type="checkbox" value="" /> 

If I use something like $dataFieldByName(Bla) to generate the input field in the template, it doesn't allow me to specify the name part of the input that I know of.

If I write out the input manually, the checkbox state isn't being saved when I go to another page/step of the form and come back.

Any Suggestions?


Community Member, 290 Posts

22 August 2011 at 8:59pm

To limit the user input with jQuery, simply count all checked children of .checkboxsetfield. Something like:

var count = $("ul.checkboxsetfield input:checked").length;