title: select multiselect option limit up to 2
body: <p>I am using multiselect for different subject's I want to limit the select up to 2 and make the other's disabled in the same way if user deselect, Again the option must be available for the user.</p>
  
  <pre><code>&lt;select multiple="multiple" class="subjects" name="subjects[]" style="float:left;width:205px;" size="5"&gt;
    &lt;option value='1'&gt;subject1&lt;/option&gt;
    &lt;option value='2'&gt;subject2&lt;/option&gt;
    &lt;option value='3'&gt;subject3&lt;/option&gt;
    &lt;option value='3'&gt;subject3&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>So far I have achieved to deselect only the last option which was selected after 2 and the code is as follow </p>
  
  <pre><code>    /**
       * Make sure the subject's limit is 2
       */
      $(".subjects option").click(function(e){
  
          if ($(this).parent().val().length &gt; 2) {
              $(this).removeAttr("selected");
          }
      });
  </code></pre>
  
  <p>Thank you.</p>