troubleshooting Question

How to validate UK telephone no

Avatar of shieldguy
shieldguyFlag for United Kingdom of Great Britain and Northern Ireland asked on
.NET ProgrammingC#ASP.NET
7 Comments1 Solution1740 ViewsLast Modified:
I am trying to create a validation function for UK telephone no.
I had created one but I am not sure what are the exact rules i should follow
the information available on internet is very ambiguous
For example if the length must be either 10 or 11 then what if the phone no also include country code or +44

public static bool IsValidTelephone(string phoneNo)
            bool rtnValid = true;
            phoneNo =  phoneNo.Replace("(", "").Replace(")", "").Replace("-", "").Trim();
            if (phoneNo.Length == 10 | phoneNo.Length== 11)
                if (!Regex.Match(phoneNo, @"^0\d{2,4}[ -]{1}[\d]{3}[\d -]{1}[\d -]{1}[\d]{1,4}$").Success)
                    return false;
                rtnValid = false;
            return rtnValid;
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 7 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros