title: Get count of selected items from asp listbox using jquery
body: <p>I am trying to get the count of selected items from an asp listbox using jquery but can't figure out how to do it. this is how I have it as of now, but I get "Cannot get property length of undefined or null reference" on selectedOptions property. <code>var lb</code> fills with 
  <code>objectHtmlSelectElement,</code> so that seems right.</p>
  
  <pre><code>function CheckSelectionCount(sender, args) {
              var lb = document.getElementById(sender.controltovalidate);
              var count = lb.selectedOptions.length;
              args.IsValid = count &gt;= 1 &amp;&amp; count &lt;= 5;
  }
  </code></pre>
  
  <p><a href="https://stackoverflow.com/questions/17885615/getting-selected-items-count-listbox-with-jquery/" title="Many similar questions">Many similar questions</a>
   remedy this using a selector combined with the :selected attribute, but I think I need to leverage the sender argument and store it in a variable.</p>
  
  <p>I'm sure this will be easy for the experts on here! Thanks in advance</p>