Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Are you asking how you can use the plugin? It's pretty well-documented, but anyway these snippets should assist. Here I take a simple form with two lots of radio-button groups, validate them using the plugin. The main things to note in the validation code are that we have two handler callbacks (for 'invalid' and 'success' states) plus a set of validation rules to apply.</p> <p>First, the example form:</p> <pre><code>&lt;form id="your-form"&gt; &lt;fieldset&gt; &lt;p&gt; &lt;label for="group_one"&gt;Select an option (required)&lt;/label&gt; &lt;input type="radio" name="group_one" id="opt1-1"&gt;Option 1 &lt;input type="radio" name="group_one" id="opt1-2"&gt;Option 2 &lt;input type="radio" name="group_one" id="opt1-3"&gt;Option 3 &lt;/p&gt; &lt;p&gt; &lt;label for="group_two"&gt;Select an option here too (required)&lt;/label&gt; &lt;input type="radio" name="group_two" id="opt2-1"&gt;Option 1 &lt;input type="radio" name="group_two" id="opt2-2"&gt;Option 2 &lt;input type="radio" name="group_two" id="opt2-3"&gt;Option 3 &lt;/p&gt; &lt;p&gt;&lt;input name="submit" type="submit" id="submit" value="Save" /&gt;&lt;/p&gt; &lt;/fieldset&gt; &lt;/form&gt; </code></pre> <p>… and second, the validation code:</p> <pre><code>$(document).ready(function(){ $("#your-form").validate({ invalidHandler: function(form, validator){ var errors = validator.numberOfInvalids(); var message = (errors == 1) ? "One of your groups won't validate." : "Neither of your groups will validate."; alert(message); }, submitHandler: function(){ alert("Everything's OK, both radio button groups are set."); $('#your-form').ajaxSubmit() }, rules: {group_one: {required: true}, group_two: {required: true}} }); }); </code></pre> <p>Does that help?</p>
 

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