RadhaKrishnaKiJaya
asked on
Validate the German and French phone numbers in MVC
Hi Experts,
Right now I have this expression to validate US phone number. It is working fine.
German - 12 digit format ( 0111 12345678)
French - 10 digit (0x xx xx xx xx)
Right now I have this expression to validate US phone number. It is working fine.
const string PhoneNumberPattern = @"^(\+?1[\-\. ])?(\(\d{3}\)|\d{3})[\-\. ]?\d{3}[\-\. ]?\d{4}$";
Please help me to write 2 more expression to validate German, French phone numbers.German - 12 digit format ( 0111 12345678)
French - 10 digit (0x xx xx xx xx)
There is no way to validate phone numbers besides looking them up or calling them.
In an international application you need to store the numbers as E.164 and use country specific formatters to display them.
In an international application you need to store the numbers as E.164 and use country specific formatters to display them.
ASKER
Hi David,
Thank you for trying to help me! The French one is working for me! But the German one should take only 12 digits. But now it is taking 3 digits too. Please help me to change the expression.
Thank you for trying to help me! The French one is working for me! But the German one should take only 12 digits. But now it is taking 3 digits too. Please help me to change the expression.
A German phone number can have more than 12 digits.
Doing line based dial telecommunications for over a decade based in Germany, but with dial-ins in the entire world: There is only one storage format, which is E.164 nowadays.
I can remember two weird cases in EU:
- A single city in Italy had a different number scheme.
- Some of the British micro isles where also not the same as the England.
And please believe me, what ever you're trying to do, it has nothing to do with phone number validation. Phone number validation requires that you split out the different parts and check the actual values for correctness. As this is not trivial, there are entire companies offering their services to do.
Doing line based dial telecommunications for over a decade based in Germany, but with dial-ins in the entire world: There is only one storage format, which is E.164 nowadays.
I can remember two weird cases in EU:
- A single city in Italy had a different number scheme.
- Some of the British micro isles where also not the same as the England.
And please believe me, what ever you're trying to do, it has nothing to do with phone number validation. Phone number validation requires that you split out the different parts and check the actual values for correctness. As this is not trivial, there are entire companies offering their services to do.
ASKER
I really respect your suggestion and trying to dig more into the business rule we need to follow. In the mean time can you please show me one example how to do it?
Thanks a lot!
Thanks a lot!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window