Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>Quote OP</strong>:</p> <blockquote> <p><em>"I want to make sure that at least one of the check boxes is selected."</em></p> </blockquote> <p>If you want to use the jQuery Validate plugin, <em>and all checkboxes have a different <code>name</code></em>, simply use the <code>require_from_group</code> method that's part of <a href="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/additional-methods.js" rel="nofollow">the <code>additional-methods.js</code> file</a>.</p> <p>Since you already have a common class on these checkboxes called <code>require-one</code>, it's even easier.</p> <pre><code>$('#form').validate({ rules: { fieldname: { require_from_group: [1, '.require-one'] }, // declare same rule on all eight checkboxes .... .... } }); </code></pre> <p>However, rather than declare all eight of these within <code>.validate()</code>, you can use the <code>.rules('add')</code> method inside of a jQuery <code>.each()</code> to declare them all at once.</p> <pre><code>$('.require-one').each(function () { $(this).rules('add', { require_from_group: [1, this], messages: { require_from_group: "please check one" } }); }); </code></pre> <p>Then to combine all eight messages into one, use the <code>groups</code> option...</p> <pre><code>$('#form').validate({ groups: { // combine these error messages into one checkboxes: 'allwines beer redwines cider whitewines spirits sparkling fortified' } }); </code></pre> <p><strong>Working DEMO: <a href="http://jsfiddle.net/JVWu2/1/" rel="nofollow">http://jsfiddle.net/JVWu2/1/</a></strong></p> <p>Placing your error message into the <code>#error_msg3</code> error box is no different than placing any of your other jQuery Validate messages.</p>
    singulars
    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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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