Reputation: 10720
<input class="span10" type="number" max="99999" ng-maxLength="5" placeholder="Enter Points" ng-change="myFunc($index)" ng-model="myVar">
This will only change the value of form.input.$valid
to false
if value is larger than 99999 or 5 digits. otherwise its true
. However , the user is still able to enter any length number. I just want to limit the digits he is entering just like maxlength of html.
Upvotes: 1
Views: 1230
Reputation: 6629
You will need to use the maxlength attribute as well. This post explains why.
Edit Seems Chrome is not honoring the maxlength when the input type is number, but it does for input type of text. Edge and IE do honor the maxlength when the input type is number. See this post for info on that.
Upvotes: 3