Validating uk phone numbers
The number must be checked for validity and length and then reformatted for display by later more detailed logic elements.
After checking the input looks like a GB telephone number using the pattern above, the next step is to extract the NSN part so that it can be checked in greater detail for validity and then formatted in the right way for the applicable number range.
This example helps you validate an international phone number by using a different approach.
We will use the intl-tel-input plugin for that purpose.
The number should be stored (in a database or wherever) in E.164 format, with sign, country code and NSN (i.e.
If you need a very simple pattern to broadly accept various GB telephone numbers as potentially valid or not, try one of these listed immediately below. Those patterns are grouped by number range usage for validation and by initial digits for formatting.
Here the data for GB, IM, GG, GJ is combined whereas libphonenumber treats them each as separate countries. Alternatively, the initial opening parentheses are followed by a literal without a following space or hyphen. Note: These area codes are very rare in GB, and are only available in the following places: 13873 (Langholm), 15242 (Hornby-with-Farleton), 15394 (Hawkshead), 15395 (Grange-over-Sands), 15396 (Sedbergh), 16973 (Wigton), 16974 (Raughton Head), 16977 (Brampton), 17683 (Appleby-in-Westmorland), 17684 (Pooley Bridge), 17687 (Keswick), 19467 (Gosforth).