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
Ratna PrabhaRatna Prabha 

validation rule for mobile number

I am new to the salesforce trying with my first customise validation rule  for the mobile no. as in this format of +91 (XXX) XXX XXXX. I am unable to get this format please any one help me in this scenario 
Best Answer chosen by Ratna Prabha
DeepthiDeepthi (Salesforce Developers) 
Hi Ratna,

Please check the below validation rule that I have created which looks for numbers starting with 7 or 8 or 9. 
NOT(
AND( (LEN(Mobile__c)==16 ),(REGEX(Mobile__c,'[+91]{3}-[7-9]{1}[0-9]{2}-[0-9]{3}-[0-9]{4}')))
)
Hope this helps you!
Best Regards,
Deepthi

 

All Answers

DeepthiDeepthi (Salesforce Developers) 
Hi Ratna,

Please check the below validation rule that I have created which looks for numbers starting with 7 or 8 or 9. 
NOT(
AND( (LEN(Mobile__c)==16 ),(REGEX(Mobile__c,'[+91]{3}-[7-9]{1}[0-9]{2}-[0-9]{3}-[0-9]{4}')))
)
Hope this helps you!
Best Regards,
Deepthi

 
This was selected as the best answer
Vijay NagarathinamVijay Nagarathinam
Hi Ratna,

Refer the below site,

https://help.salesforce.com/apex/HTViewSolution?id=000187896&language=en_US
NOT(REGEX(Account__r.Phone,"[+91]{3}-[0-9]{3}-[0-9]{3}-[0-9]{4}"))

Let me know if you need any help regarding this.

Thanks,
Vijay
Ratna PrabhaRatna Prabha
Thanks, Deepthi. 
Igor PetrovychIgor Petrovych
If you need a more advanced validation of a number, to make sure you really have a valid number - you can do that in the trigger handler, and use a ported libphonenumber (https://appexchange.salesforce.com/appxListingDetail?listingId=a0N3A00000G12oJUAR) library.