First though, let’s look at the issue of collecting telephone numbers. However, because of the issues around the variations in format, it doesn’t actually place any restrictions on what the user can type, nor does it perform any validation in the same way as, say, the email element.Nevertheless, there are some advantages – when used on a mobile site a user’s telephone keypad will usually be displayed, rather than a conventional keyboard layout.Names aren’t as straightforward as they sound, but provided you cater for edge cases and international variations – for example patronymics, the mononymous, or even just people with hyphenated surnames – you can’t go too far wrong (although plenty of applications and services do! Email addresses, while theoretically very easy to validate, have their own challenges – yet nevertheless, there are plenty of regular expressions in the wild that aren’t quite right. All sorts of external factors can have implications for telephone numbering.
But for anything remotely automated – such as sending SMS messages – or to validate them effectively, you’ll need to capture the country prefix.Even international dialing codes, however, aren’t as straightforward as you may think.The format can vary – 1, 43, 962 1868 are all valid codes.From abroad, to call a UK number you need to drop the leading zero and prefix with the dialing code 44: Thankfully, there is a format we can use which enable us to get around these variations.Luckily for developers there is an unambiguous, internationally recognized standard for telephone numbers anywhere in the World called E.164.