I have an input field of number type.I want that anyone can only enter 4 digits on that field. How Can I achieve it?
Asked
Active
Viewed 989 times
0
-
Try setting, my friend . – Tomato32 Nov 19 '18 at 13:23
1 Answers
0
To prevent more than 4 characters from being entered in the input field, set a maximum length:
<input maxlength="4">
This is the most basic way to achieve that. There are other ways to do it depending on whether or not you are using template or reactive forms. See the Angular guide for form validation: https://v5.angular.io/guide/form-validation.

G. Tranter
- 16,766
- 1
- 48
- 68