function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Michael Sabel 9Michael Sabel 9 

How to allow for extensions with my phone number format validation rule?

Hi, this Validation Rule works for me. It ensures the format is the following: (xxx) xxx-xxxx.

AND(
NOT(ISBLANK(HomePhone)),
NOT(REGEX(HomePhone, "\\([0-9]{3}\\) [0-9]{3}-[0-9]{4}"))
)

Question: How can I amend the rule to allow for phone extensions? If I wanted to keep the existing phone format requirement but allow for "Ext. xxxxx" only, what would I need to do in my Validation Rule? Thanks much

Mike
Devi ChandrikaDevi Chandrika (Salesforce Developers) 
Hi Mike,
Can you provide an example format of the phone number which you want to validate
Amy KerdolffAmy Kerdolff
I have the same question, but with a slightly different formula that requires phone numbers to be in the following format: ###-###-####

NOT(ISBLANK( HomePhone ))
&&
NOT(REGEX( HomePhone , "[0-9]{3}-[0-9]{3}-[0-9]{4}") )

I would like my users to also be able to save a phone number that is formatted as ###-###-#### ext. ####