I am developing first time in angular and my requirement is the input should take only digits up to length 10.
After lot of searches I know that I can either use input type as number which will restrict only numbers but the issue with this is it allows e character as exponential sigh and - sign for the math numbers. I do not want this. What I need is the text area should only allow numbers up to length 10 chars.
Hence I am using input type as text like below:
in my component template I defined something like below:
$
<div class="number">
<input type="text" formControlName="Q4a" maxlength="10" ng-
pattern="onlyNumbers" required /><!"/^[0-9]{1,7}$" ---->
</div>
onlyNumbers = '/^\d+$/';
$
but this does not work. The max length allowed is 10 chars but it does allow characters.
How do I achieve what I need, which is an input area that allows only digits up to 10 characters?