Dear All,
I need to know the regular expression for accepting phone number for following formats.
1234567890
123 456 7890
123-456-7890
Can anybody resolve this issue?
Thanks,
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
VulpesRank #55 · 29.2K reputationPosted Apr 12, 2012, 3:12 AM EDT
@"^\d{10}$"
@"^\d{3} \d{3} \d{4}$"
@"^\d{3}-\d{3}-\d{4}$"
SenthilkumarRank #387 · 6.5K reputationPosted Apr 12, 2012, 3:13 AM EDT
try this...
123-456-7890 => \d{3}-\d{3}-\d{4}
1234567890 = > ^([1-9]{1})([0-9]{9})$
123-456-7890 => ^(1?(-?\d{3})-?)?(\d{3})(-?\d{4})$
more info:
http://msdn.microsoft.com/en-us/library/ff650303.aspx
http://www.zparacha.com/phone_number_regex/#.T4a4llH9PdM
MuthuMari MRank #5,738 · 288 reputationPosted Apr 12, 2012, 3:14 AM EDT
pls refer this url ,
http://msdn.microsoft.com/en-us/library/ff650303.aspx
http://asp-net-example.blogspot.in/2009/02/aspnet-regularexpressionvalidator_2294.html
thanks.
If this post is useful then mark it as "Accepted Answer"
johny basha36 reputationPosted Apr 12, 2012, 3:44 AM EDT
thanks,its working ,but can i validate the textbox to enter in both formats like
1234567890
123-456-7890
thanks,
VulpesRank #55 · 29.2K reputationPosted Apr 12, 2012, 5:02 AM EDT
(A|B)
johny basha36 reputationPosted Apr 12, 2012, 6:05 AM EDT