candreoliveira / ngMask

Best Angular mask alternative! No jQuery, pure JS. About ~6kb!
http://candreoliveira.github.io/#/ngMask
ISC License
419 stars 171 forks source link

Mask that accepts only 10 or 14 digits, for example #141

Closed peresbruno closed 7 years ago

peresbruno commented 7 years ago

Hello.

With ngMask is possible to creat a mask that accepts, for example, only 10 or 14 digits? For example:

input value = 999999999 (9 digits, valid)
input value = 9999999999 (10 digits, valid)
input value = 99999999999 (11 digits, invalid)
input value = 999999999999 (12 digits, invalid)
input value = 9999999999999 (13 digits, invalid)
input value = 99999999999999 (14 digits, valid)
input value = 999999999999999 (15 digits, invalid)

Thanks :)

peresbruno commented 7 years ago

Hi, solved in conjunction with a ng-pattern :)

Like this:

<input type="tel" name="input" ng-model="phone" ng-required="config.required" ng-pattern="/^\+\d{12}(?:\d{4})?$/" mask="+9999999999999?9?9?9?" >

I'm closing this issue

thanks