Note that there are some explanatory texts on larger screens.

plurals
  1. POLimit Checkboxes to Only Three Checkboxes - How?
    primarykey
    data
    text
    <p>I have many checkboxes on a form. I need to limit the total to three checkboxes selected and no more. I had code that worked but I just upgraded my forms to Foundation Custom Forms and my script no longer works and I cannot get it to work. </p> <p>How do I re-write the script to work?</p> <p>Here is the current script: </p> <pre><code>$(function(){ var max = 3; var checkboxes = $('input[type="checkbox"]'); checkboxes.click(function(){ var $this = $(this); var set = $this.add($this.prevUntil('label')).add($this.nextUntil('label')); var current = set.filter(':checked').length; return current &lt;= max; }); }); </code></pre> <p>Here is the form code: </p> <pre><code>&lt;label&gt;Effects &lt;span class="red"&gt;required&lt;/span&gt;&lt;/label&gt; &lt;label for="CAT_Custom_365571_0"&gt;&lt;input type="checkbox" value="Creative" id="CAT_Custom_365571_0" name="CAT_Custom_365571" style="display: none;"&gt; &lt;span class="custom checkbox"&gt;&lt;/span&gt; Creative&lt;/label&gt; &lt;label for="CAT_Custom_365571_1"&gt;&lt;input type="checkbox" value="Euphoric" id="CAT_Custom_365571_1" name="CAT_Custom_365571" style="display: none;"&gt; &lt;span class="custom checkbox"&gt;&lt;/span&gt; Euphoric&lt;/label&gt; &lt;label for="CAT_Custom_365571_2"&gt;&lt;input type="checkbox" value="Uplifted" id="CAT_Custom_365571_2" name="CAT_Custom_365571" style="display: none;"&gt; &lt;span class="custom checkbox"&gt;&lt;/span&gt; Uplifted&lt;/label&gt; &lt;label for="CAT_Custom_365571_3"&gt;&lt;input type="checkbox" value="Energetic" id="CAT_Custom_365571_3" name="CAT_Custom_365571" style="display: none;"&gt; &lt;span class="custom checkbox"&gt;&lt;/span&gt; Energetic&lt;/label&gt; &lt;label for="CAT_Custom_365571_4"&gt;&lt;input type="checkbox" value="Lazy" id="CAT_Custom_365571_4" name="CAT_Custom_365571" style="display: none;"&gt; &lt;span class="custom checkbox"&gt;&lt;/span&gt; Lazy&lt;/label&gt; &lt;label for="CAT_Custom_365571_5"&gt;&lt;input type="checkbox" value="Focused" id="CAT_Custom_365571_5" name="CAT_Custom_365571" style="display: none;"&gt; &lt;span class="custom checkbox"&gt;&lt;/span&gt; Focused&lt;/label&gt; &lt;!-- MORE CHECKBOXES --&gt; </code></pre> <p>Obviously when I changed the forms I broke the script. How do I fix this?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload