0

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?

1 Answers1

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