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?
How to add max digit number validation in angular material 5?
1k views Asked by Noymul Islam Chowdhury At
1
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?
To prevent more than 4 characters from being entered in the input field, set a maximum length:
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.