I want to create a validation rule on Phone field(Custom) where system will be allowed to use + or 00 and then 7 to 26 digits(Numeric). Also in between if I enter any space or dash that should not be counted in this limit.

eg: +49 1521 4846987364 or 0049 1521 4846987364 System can save this number where it will read total characters as 16 excluding ( ) and +/00

+49 75681 94875419854719485473 or 0049 75681 94875419854719485473 system will throw an error here since total digits here are more than 26

+49 7382 or 0049 7382 system will throw an error here since total digits here are 6 ie <7.


2 Answers 2


I would recommend a two step approach. First keep your length restrictions on hold and go and find a well tested working solution for phone numbers. You don't have to reinvent the wheel:

try as formula then something like:

  REGEX( SamplePhone__c, "^\\+([0-9 ]+)$" ) 
  &&  LEN(  SUBSTITUTE(SamplePhone__c , " ", "")   ) < 26  
  &&  LEN(  SUBSTITUTE(SamplePhone__c , " ", "")   ) > 6 

Replace the regex to the one of your choice and use nested SUBSTITUE(...) to remove other character you don't want to count against your Min and Max.

The idea is to decouple the regex and the length checks and combine them logically.


When you enter phone numbers in various phone fields, Salesforce preserves whatever phone number format you enter. If your Salesforce Org Locale is set to English (United States) or English (Canada). Salesforce does following things by the JavaScript.

  1. If telephone number contains 9 digits - It will be Saved as it is in Salesforce - Ex: 949243871

  2. If telephone number contains 10 digit - It will be Saved as : (895) 623-1245

  3. If telephone number contains 11 digits there are 2 cases · If 11 digit number starts with 1 it will automatically convert in the 10 digit format by removing the 1 in the number Ex: If the number is like this => 12365478963 It will be saved as in Salesforce => (236) 547-8963 Note: It removes the 1 and formats the other numbers as like 10 Digit Number.

If 11 digits but not starting with the 1 then it will stored as it is in the Salesforce. Ex: If the number is like this => 23654789631 It will be saved as in Salesforce => 23654789631

If you do not want this formatting for a ten- or eleven-digit number, enter a “+” before the number, for example, +49 1234 56 78-0. Note: A phone field can accept a maximum of 40 digits to be entered in the field. Also note that this can only be done via User Interface and NOT via the API.

For your reference, here are the articles related to your issue:

Guidelines for Entering Currency, Dates, Times, and Phone Numbers https://help.salesforce.com/HTViewHelpDoc?id=basics_understanding_values_curr_date_phone.htm&language=en_US

Need Standard Telephone Fomating https://success.salesforce.com/answers?id=90630000000giggAAA

Phone number formula help https://success.salesforce.com/answers?id=90630000000gnt4AAA

Field formula to remove spaces, dashes, and special characters from value https://success.salesforce.com/answers?id=90630000000h0fEAAQ

Is there a phone number format 'best practice'? https://success.salesforce.com/answers?id=90630000000gs7SAAQ

Is there a way to automatically format a phone number field... https://success.salesforce.com/answers?id=90630000000goKBAA

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .