Nathan R

Nathan R

  • NA
  • 13
  • 15.5k

c# code to check mobile phone number format

Mar 18 2014 7:09 AM
Sir,
 
 
I need your help to find a c# code to check the mobile phone number format with country code.
 
the phone number value in database column is  like this:- '91XXXXXXXXXX' .
 
Please provide me the proper code to check the 12 digit number  
 
the problem is in the line marked red.
 
My current code is:-
 
private static readonly Regex phoneNumber = new Regex(@"\d{2}-\d{3}-\d{3}-\d{4}");
 
public static bool VerifyPhoneNumber(string pNumber)
{
return phoneNumber.IsMatch(pNumber);
}
 
And   my function only need to execute if the format is correct.
 
I did:-
 
if(VerifyPhoneNumber(Phone))
{
 
}
 

Answers (3)