title: Limiting words in textarea with AngularJS
body: <p>I have been trying to limit words in text area using AngularJS.
  So far I have tried this </p>
  
  <h3>Textarea HTML</h3>
  
  <pre><code>&lt;textarea ng-model="man_abs" style="height: 100px;" id="manuscriptabstract" name="manuscriptabstract" placeholder="Maximum 250 Words" class="form-control" ng-change="wordCount()" required=""&gt;&lt;/textarea&gt;
  &lt;span class="help-block"&gt;{{251 - man_abs.split(' ').length}} words left&lt;/span&gt;
  </code></pre>
  
  <h3>AngularJS script</h3>
  
  <pre><code>$scope.wordCount = function() {
      if ($scope.man_abs != undefined) {
          var key_length = $scope.man_abs.split(' ').length;
          if (key_length &gt;= 251) {
             $scope.man_abs = $scope.man_abs.substring(0, $scope.man_abs.lastIndexOf(" "));
             alert("You are allowed to enter only 250 words in this field");
          }
      }
  }
  </code></pre>
  
  <p>I seems to work fine ,but when I  copy paste a paragraph more than 250 words ,it is not working as expected. </p>
  
  <p>I have tried preventDefault() method and it is not working.
  I need to make sure that user should not be able to type more than 250 words, If Copy pasted , after 250th word the sentence have to be removed.. </p>