Jquery validate checkbox by class name
<p>i want to validate check box by jquery validation adding rule and message. i did this way but some where i made the mistake for which code is not working.</p>

<p>i want user has to select one checkbox at least before form submit.</p>

<h2>code</h2>

<pre><code>&lt;form id="myform"&gt;
    &lt;input type="checkbox" name="test[]" class="clschk" /&gt;x
    &lt;input type="checkbox" name="test[]"  class="clschk"/&gt;y
    &lt;input type="checkbox" name="test[]"  class="clschk"/&gt;z
    &lt;input type="submit" /&gt;
&lt;/form&gt;
&lt;a id="docs" href="http://docs.jquery.com/Plugins/Validation" target="_blank"&gt;Validation Documentation&lt;/a&gt;
</code></pre>

<h2>js code</h2>

<pre><code>$(document).ready(function () {
    $('#myform').validate({ // initialize the plugin
        rules: {
            '.clschk': {
                required: true,
                maxlength: 2
            }
        },
        messages: {
            '.clschk': {
                required: "You must check at least 1 box",
                maxlength: "Check no more than {0} boxes"
            }
        },
        submitHandler: function (form) { // for demo
            alert('valid form submitted'); // for demo
            return false; // for demo
        }
    });
});
</code></pre>