+2 votes
There is a list of numbers, and how you need to store all these numbers in one format. For example, the API can do the numbers in the following formats:
+7 777 777 77 77
8 777 777 77 77
777 777 77 77
And the whole thing should be kept in the same form as one number - 77777777777
As does iOS? For example, if you dial any of these numbers, in any case, get on one.
No matter where to handle the rooms, though on the server (PHP), at least at the front (Swift, Objective-C)
The difficulty lies not in this. Can there be a code of another country, that's difficult.
In the end, it was crossed variant https://github.com/giggsey/libphonenumber-for-php
As it turned out, there is a module for kokhany https://github.com/softmediadev/kohana-phonenumber
If suddenly to whom it is necessary :)

3 Answers

0 votes
Best answer
there are links to ports for different languages
+1 vote
Well, if for different countries, it is necessary to first customer has selected a country from the list, and then enter a room without the code.
It is in Russia +7 (xxx) xxx-xx-xx, but somewhere like +345 (xxxx) xxx-xxx
I think there is a ready plugin with a list of countries
+2 votes
How do I for web:
He put on the input regexp that formats a number to fit my format, and then check it on the server already, if suddenly switched the room with some TamperData.

On the server, remove all dashes, parentheses and spaces. Next, check the size of the room, there are two options possible with 7/8 or without. All if it met all the conditions - write to database.
Nikita Kamenev Unfortunately the script is not passed the primitive tests :(
Nikita Kamenev : Thanks! Now look!
So far it works, but can't figure out what to do with other countries? There is no code +7 and internal 8
dimash07 then, maybe you can help this article is habrahabr.ru/post/102352