how to write validation rules for phone number in below format


Example : +(91)-1234567890

When end user entering value for phone number it should only allow mentioned special characters + () - and numeric numbers.

exiting validation rule

IF( ISBLANK(End_User_Contact_Phone__c) , false, NOT(REGEX(End_User_Contact_Phone__c, "\D*?(\d\D*?){10}")))

  • I modified like this. is it right ? IF( ISBLANK(End_User_Contact_Phone__c) , false, NOT(REGEX(End_User_Contact_Phone__c,"^(\\+)[\(\)-][0-9]"))) – user10584 Jul 28 '14 at 10:09

This should do the trick given the requirements:

NOT(REGEX(Phone, "[0-9+\\-\\(\\)]*"))

But it will allow for some funky phone numbers that are definitely not valid, e.g. "+123-+()()()"

  • If this is the answer that worked you should mark it as accepted (tick next to it). This isn't me angling for points, but it helps identify the solution to those searching later on, and it also helps our site stats! – Matt Lacey Jul 31 '14 at 5:10
  • NOT(REGEX(Phone_Number__c, "[0-9+\\-\(\)]*")) using validation rules.It's auto formating in US format but when record save in application.It's throwing message. Just I want to need to add space in validation rule. How can I add. – user10584 Aug 1 '14 at 4:55
  • 1
    As per @LaceySnr's answer, just following the regex, escape the whitespace character \s. So your new regex will look like : NOT(REGEX(Phone, "[0-9+\\-\\(\\)\\s]*")) – Boris Bachovski Aug 1 '14 at 5:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.