1779 Posts in 582 Topics by 556 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 563 Views |
-
Validate - Limit # of Checkboxes or Customize Name within Input

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.
ie.
<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?
-
Re: Validate - Limit # of Checkboxes or Customize Name within Input

22 August 2011 at 8:59pm
http://api.silverstripe.org/trunk/forms/fields-basic/CheckboxSetField.html
To limit the user input with jQuery, simply count all checked children of .checkboxsetfield. Something like:
var count = $("ul.checkboxsetfield input:checked").length;
| 563 Views | ||
|
Page:
1
|
Go to Top |


