How in php to validate the phone number?

0 like 0 dislike
3 views
Hello!
I use the library Inputmask
There is a mask for typing phone https://github.com/RobinHerbots/Inputmask/blob/4.x...

format:
+376-###-### +971-5#-###-#### +971-#-###-#### +93-##-###-####


What is the easiest way in php for me to check the compliance to these masks?
by | 3 views

1 Answer

0 like 0 dislike
Write a regular expression using preg_match and check
+376-###-###
/^(\\+376)-(\\d{3})-(\\d{3})$/g


+971-5#-###-####
/^(\\+971)-(5\\d{1})-(\\d{3})-(\\d{4}))$/g


Assembly of all expressions recommend using https://regex101.com/ There and validation, and tips and much more useful.

If we need expressions for the other rooms try to make yourself not do it, write here in the comments, write
by

Related questions

0 like 0 dislike
2 answers
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
110,608 questions
257,186 answers
0 comments
28,644 users