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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
johny bashaPosted Apr 12, 2012, 10:05 AM
VulpesPosted Apr 12, 2012, 9:02 AM
(A|B)
johny bashaPosted Apr 12, 2012, 7:44 AM
thanks,its working ,but can i validate the textbox to enter in both formats like
1234567890
123-456-7890
thanks,
MuthuMari MPosted Apr 12, 2012, 7:14 AM
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"
SenthilkumarPosted Apr 12, 2012, 7:13 AM
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
VulpesPosted Apr 12, 2012, 7:12 AM
@"^\d{10}$"
@"^\d{3} \d{3} \d{4}$"
@"^\d{3}-\d{3}-\d{4}$"