title: Checkboxlist validation failing because length of list of checkboxes is always zero
body: <p>I have a checkbox list and I'm trying to validate it so that the user should select at least one checkbox. For this checkbox list I'm binding the values from the database. This list is on a partial view.</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;div class="options" data-bind="foreach: User,
                                  visible: true" style="display: none;"&gt;
    &lt;input type="checkbox" 
           id="chk" 
           class='roles' 
           name='roles' 
           data-bind="attr: { value: Id }, 
                      checked:MyViewModel.MyData.UserCheckedValues" /&gt;
    &lt;span data-bind="text: Name"&gt;&lt;/span&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>This is the code I tried for validating it:</p>
  
  <pre><code>   if ($('#chk input:checked').length &gt; 0) {
          return true;
      }
      else {
          alert('Please select atleast one technology')
          return false;
      }
  </code></pre>
  
  <p>However, every time I'm getting length 0 even when I select the checkbox. How can I validate this checkbox list?</p>