This would need to be updated for international numbers, or to allow users to enter phone numbers using letter representation.
In a real case, this function would probably be called as part of a larger validate form function.
This notation requires that international phone numbers include a leading plus sign (known as the ), and allows only spaces to separate groups of digits. EPP is a relatively recent protocol (finalized in 2004), designed for communication between domain name registries and registrars.
Although the tilde character (~) can appear within a phone number to indicate the existence of an additional dial tone, it has been excluded from this regular expression since it is merely a procedural element (in other words, it is not actually dialed) and is infrequently used. It is used by a growing number of domain name registries, including .