ShowAll Questionssorted byDate Posted
Alv von der Decken

# Validation rule for phone number format (regex)

I need your help in order to create a validation rule for telephone number to following format (german phone number system):

"+49", than "-" followed by 3 to 4 digits (0-9), than forced "-" followed by 3 to x digits digits (0-9), possible but not forced "-" followed by 1 to x digits (0-9).

Examples:
+49-123-123
+49-123-1234567
+49-1234-123456789-0
+49-1234-123-123456789

Can anyone create a regex for me?

Thank you very much in advance.
Eric Praud
Hi,

try this:
NOT(OR(REGEX( Phone , "[+49]{3}-[0-9]{3}-[0-9]{3}"),

REGEX( Phone , "[+49]{3}-[0-9]{3}-[0-9]{7}"),
REGEX( Phone , "[+49]{3}-[0-9]{4}-[0-9]{9}-[0-9]{1}"),
REGEX( Phone , "[+49]{3}-[0-9]{4}-[0-9]{3}-[0-9]{9}")))

Let me know if this works, thanks
Alv von der Decken
Hello and thanks a lot.

I changed to following and it works just fine:

NOT( OR(
OR( LEN(  Phone  ) = 0,
REGEX(Phone, "[+49]{3}-[1-9]{1}[0-9]{2,3}-[0-9]{3,9}") ,
REGEX(Phone, "[+49]{3}-[1-9]{1}[0-9]{2,3}-[0-9]{3,9}-[0-9]{1,9}"))))
Mantrala Ranjeeth kumar
@Eric Praud can u please explain me the formula how it works ...?

step wise :)

im a newbie having the same problem
Iain Clements
This is a great question and one we have come across a lot. It inspired us to write an app called RingsTrue which will help with this type of issue.

RingsTrue will launch soon on the @AppExchange and will run through all of your telephone records in Salesforce, tidy them, validate them, and then check whether they are in service or not.

If you still need any help validating your phone records please check it out.

#ringstrue #telephonevalidation
Aarya Tiwary
If the Format is +19042380274 ??
Then what is the format(regex)
Saifullah Saifi
REGEX( phone , "[+19]{3}[0-9]{3} [0-9]{3} [0-9]{3}")
Eran Alaton
Hey
Is there any option to use this formula for a few standard/custom fields?
if i take this part for example:
NOT(OR(REGEX( Phone , "[+49]{3}-[0-9]{3}-[0-9]{3}")))
But I ask to inclidue also the "Fax" field

So where am I suposed to type the Fax in this row?