Reputation: 12729
Could you please tell me how to restrict user not to enter ten character in name field? If user enter more than 10 character than he will not able to enter that. Please suggest a better way?
http://plnkr.co/edit/w1cidR23RYLAYE6dlvXd?p=preview I have a name field in which user only enter ten digit name not more than that. If the user try to enter more it not allow.
<td ng-if="value.type == 'FIELD' && isEditableMode && value.editable && value.dataType!='DATE'">
<div class="form-group" ng-class="{'has-error': myform[key].$invalid}">
<input type="text" name="{{key}}" class="form-control" ng-model="value.value">
</div>
</td>
Upvotes: 1
Views: 3165
Reputation: 68933
You can simply set the maxlength
attribute.
The
maxlength
attribute specifies the maximum number of characters allowed in the input element.
Demo:
<input maxlength="10" type="text"/>
Upvotes: 2
Reputation: 545
There are 2 attributes that allow you to add a minimum and maximum to your input they are min and max
so just add max ="10" into your input tag
Upvotes: 1