function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
TheRenceTheRence 

UK Telephone Number Validation

Hi,

 

I am trying to write a validation formula that will allow two format types for UK phone numbers, these are;

01234 567890 and 0123 456 7890.

 

Whilst I can write a validation rule for one format type; 

 

NOT(REGEX(Phone, "\\d{4}( \\d{3})( \\d{4})")).

 

I cannot seem to write a rule that will allow for two. I had tried;

 

OR(NOT(REGEX(Phone, "\\d{4}( \\d{3})( \\d{4})")), NOT(REGEX(Phone, "\\d{5}( \\d{6})")))

 

But this does not work. Any advice to what I am hoping is a simple answer would be grateful.

wgrawgra

This one should work:

 

 

AND( NOT(REGEX(Phone, "\\d{4}( \\d{3})( \\d{4})")), NOT(REGEX(Phone, "\\d{5}( \\d{6})")) )

 

 Werner

 

 

 

spr701spr701

TheRence wrote:

 

I am trying to write a validation formula that will allow two format types for UK phone numbers, these are;

01234 567890 and 0123 456 7890.

 


 

There are very many more formats than just those two. Additionally, your second format isn't valid for the actual number range used in your example.

 

UK telephone numbers begin with the 0 trunk code or the +44 country code. One of these is placed before the area code and that is followed by a space and finally the subscriber number.

 

Not all UK numbers have 10 digits. Some have 9 or in a few rare cases, only 7 digits.

 

The area code can have between 2 and 5 digits. The subscriber number has between 4 and 8 digits.

 

 

10 digit NSN

    (013873) xxxxx
    (015242) xxxxx
    (015394) xxxxx
    (015395) xxxxx
    (015396) xxxxx
    (016973) xxxxx
    (016974) xxxxx
    (016977) xxxxx
    (017683) xxxxx
    (017684) xxxxx
    (017687) xxxxx
    (019467) xxxxx
    (011x) xxx xxxx
    (01x1) xxx xxxx
    (01xxx) xxxxxx
    (02x) xxxx xxxx
    03xx xxx xxxx
    055 xxxx xxxx
    056 xxxx xxxx
    070 xxxx xxxx
    07624 xxxxxx
    076 xxxx xxxx
    07xxx xxxxxx
    08xx xxx xxxx
    09xx xxx xxxx

 

 

9 digit NSN

    (016977) 2xxx
    (016977) 3xxx
    (01xxx) xxxxx
    0500 xxxxxx
    0800 xxxxxx

 

 

7 digit NSN


    0800 1111
    0845 46 4x

 

 

 

Valid formats for geographic numbers include 2+8, 3+7, 4+6, 4+5, 5+5 and 5+4 (and 0+10 for NDO** numbers).

Non-geographic numbers mostly use 0+10 format, but some 0800 numbers and all 0500 numbers use 0+9 format.

 

There's also one 0800 number and one 0845 number using 0+7 format.

 

 

**(NDO is National Dialling Only)



LifeportLifeport

Hii I am trying thsi javascript validation for Uk numbers validation with space in numbers where i am wrong ?

 

if (document.forms[0].phone.value == "")
{alert("You did not enter your Phone No.Please provide it.");
document.forms[0].phone.focus();return false;
}
var input=0;
input=document.forms[0].phone.value;
re = ^0\d{2,4}[ -]{1}[\d]{3}[\d -]{1}[\d -]{1}[\d]{1,4}$;
if(re.test(input) == false) {
alert('Phone number can contain only digits');
document.forms[0].phone.focus();
return false;
} else if(input.length < 11) {
alert('Phone number must be greater then 10 digits');
return false;
}

Keira ArnotKeira Arnot
The developer forum has been working very well since its inception. You must check this https://cnumber.co.uk/area-codes/01733/ site to get the 01733 number and info about cNumber as we know the things are getting better day by day. Salesforce is advancing in the corresponding field at a very high speed.