title: Javascript / JQuery: How do I count the words separated with a comma?
body: <p>Javascript:</p>
  
  <pre><code>$(document).ready(function()
  {
      $('#field').keyup(function()
      {
          var count = '??';
  
          $('#count').html(count);
      });
  });
  </code></pre>
  
  <p>HTML:</p>
  
  <pre><code>&lt;input type="text" id="field" /&gt; &lt;span id="count"&gt;5&lt;/span&gt;
  </code></pre>
  
  <p>Examples (words are always separated with a comma):</p>
  
  <pre><code>example 1: word, word word
  count: (5 - 2) = 3
  
  example 2: word
  count: (5 - 1) = 4
  
  example 3: word, word,
  count: (5 - 2) = 3
  
  example 4: word, word, word
  count: (5 - 3) = 2
  </code></pre>
  
  <p>So, I need to count how many words there are separated with a comma, but for example as shown in <strong>example 3</strong>, it should not count them as <strong>3 words</strong> only when there is a word also AFTER a comma.</p>
  
  <p>And a user should not be allowed to enter more than 5 words.</p>