Making Textarea character limit is quite simple using AngularJS, You can set the limit of character using maxlength
. The maxlength
attribute specifies the maximum number of characters allowed in the form inputs.
I'm not writing any addition JavaScript code to make this simple feature, Just setting the maximum character length, reducing and displaying the balance character count in template.
HTML
<div ng-app="" class="container">
<div>
<label>Message</label>
<textarea rows="3" class="form-control" ng-model="inputMessage" maxlength="100"></textarea>
<p class="text-right">{{ 100 - inputMessage.length + ' Char' }}</p>
</div>
</div>