title: count words in input field from datepicker
body: <p>I chose the calendar days using the datepicker. Marking days on the calendar - the date is written in the INPUT, separated by commas like this:</p>
  
  <pre><code>&lt;input type="text" id="altField" value="2015-09-25, 2015-09-26"&gt;
  </code></pre>
  
  <p>It works, but I want also display number of selected days. With lenght I decided to count the number of words that are in input like days.</p>
  
  <pre><code>&lt;div id="result"&gt;&lt;/div&gt;
  
  &lt;script&gt;
  function dayCount( val ){
      return {
          days              : val.match(/\S+/g).length
      }
  }
  var $div = $('#result');
  $('#altField').on('input', function(){
    var c = dayCount( this.value );
    $div.html(
        "&lt;br&gt;Days: "+ c.days
    );
  });
  &lt;/script&gt;
  </code></pre>
  
  <p>But it is not working. If I input words byth keyboard or copy paste them i  to input field script counts them, but if values comes from calendar script doesnt count them. What shoul i change?</p>