Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

(Angular2/4/5/6) How to validate length of international phone numbers according to country

is there a library/service class available to validate international mobile numbers individually? E.g. Singapore mobile number must have 8 digits, China 11 digits, etc. Currently I'm using ng4-intl-phone in reactive form format to allow user to input their mobile numbers.

The validations should appear according to each country and not a general check for international phone numbers like the number is from 3 to 14 digits (It was what I was using previously).

Appreciate your help!

UPDATE

I used https://www.npmjs.com/package/ngx-international-phone-number for the time being instead. I'll still leave those answers below if anyone needs to use them for reference!

like image 343
iBlehhz Avatar asked Oct 16 '22 08:10

iBlehhz


1 Answers

I have used libphonenumber-js in my angular 6 project and it works perfectly fine.

like image 156
Franklin Pious Avatar answered Oct 20 '22 04:10

Franklin Pious