The function ISPHONE outputs TRUE if the given string is a valid phone number.
This function takes a string as input. It then checks to see if the given string is a valid phone number and outputs TRUE if it is, FALSE if it isn't.
ISPHONE(string) -> result
- string (required, type: string | phone)
- The string that may or may not be a valid phone number.
- result (type: boolean)
- The result of checking if the given string is a valid phone number; TRUE means that it is and FALSE means that it isn't.
ISPHONE("(314)325-1156") -> FALSE
ISPHONE("+1(314)325-1156") -> TRUE
The previous examples entered the potential phone number with parenthesis around the area code and a hyphen between the exchange code and the four-digit number. This is not required for the ISPHONE function to recognize a string as a valid phone number. In the following example, ISPHONE recognizes "+13143251156" as a valid phone number despite this string having no parenthesis or hyphens at all:
ISPHONE("+13143251156") -> TRUE
In fact, the ISPHONE function ignores the placement of parentheses and hyphens entirely when evaluating whether the given string is a valid phone number. The following example has hyphens and a parenthesis inserted indiscriminately, and ISPHONE still recognizes it as a valid phone number:
ISPHONE("+13(1-43-25-1156") -> TRUE
However, while ISPHONE allows for such unconventional formatting when it comes to the bulk of the phone number, it is not so lax when it comes to the country calling code. By convention, country codes are prefixed with a plus sign, and without one, ISPHONE will not recognize a string as a valid phone number:
ISPHONE("13143251156") -> FALSE
ISPHONE("+15553251156") -> FALSE
A country calling code is the first thing that must be dialed in order to reach a phone line in another country. Because a country calling code is not required when connecting phones registered in the same region, many people might not think to include their country calling code when entering their phone number into an app. Apps, however, work internationally, and so it is often necessary to declare a country code explicitly. Ensuring this is done correctly by validating a phone number entered by the user is one of the major use cases for ISPHONE. When used in tandem with FORMAT_PHONE, it's possible to construct an app that stores valid phone numbers – including the country code – without requiring users to change their instinctive behavior (resulting in a more seamless user experience overall!).