hi there,
i may have asked this question several times, but the tel number is being formated in a incorrect way.
when the user enters the tel number i run the below code
public bool ValidateTelNo(string TelNo)
{
bool value = false;
string rePhoneNumber = @"\d{3}\s?\d{3}\d{4}$";
string PhoneNoFormat = @"\(\d{3}\)\s?\d{3}\-\d{4}$";
Regex re = new Regex(rePhoneNumber);
Regex re1 = new Regex(PhoneNoFormat);
if (re.IsMatch(TelNo) || (re1.IsMatch(TelNo)))
value = true;
else
value = false;
return value;
}
and then i run the second code which is shown below.
for example if the user enters 12345678901
the tel number will be formatted as (1234) 567-8901
how can i fix this so the it will return a error message saying invalid tel number the format should be (xxx) xxx-xxxx
please can some one guide me
thanks
public string CheckingValue(string Value)
{
long value = 0;
string str = Value;
bool bChecking = long.TryParse(str, out value);
if (bChecking)
{
str = String.Format("{0:(###) ###-####}", value);
}
return str;
}