Skip to content
Advertisement

How to validate input number length with angular?

I want to validate a 9 digits number using angular,

this is in my modal :

JavaScript

i tried pattern = [0-9]{9}, seems its passing every number that its getting . I want to pass only number 000000000 – 9999999999 , min-max also not working for me.

this is what my app adding to this class:

JavaScript

thank u !

Advertisement

Answer

Have you tried both ngMinlength and ngMaxlength at the same time?

Example:

JavaScript

Check out the official documentation regarding this: https://docs.angularjs.org/api/ng/directive/input

Very nice tutorial about form validation: http://www.ng-newsletter.com/posts/validations.html

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement