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
Srinivas AnnamSrinivas Annam 

how do you write validation rule for us formated ohn number?

DeepthiDeepthi (Salesforce Developers) 
Hi Srinivas,

Please check the below code that validates for mobile numbers with +91-xxx-xxx-xxxx format and the mobile number should start 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
JyothsnaJyothsna (Salesforce Developers) 
Hi Srinivas,


 1.Validates that the Phone number is in (999) 999-9999 format. This works by using the REGEX function to check that the number has ten digits in the (999) 999-9999 format.​
 
NOT(REGEX(Phone, "\\D*?(\\d\\D*?){10}"))
2. Mobile number +91-999-999-9999​ format
NOT(REGEX(Account__r.Phone,"[+91]{3}-[0-9]{3}-[0-9]{3}-[0-9]{4}"))

Stepwise
 
​[+91]{3} :
 Ensure that number starts with +91​
 
​-[1-9]{1}[0-9]{2,3}-

 Ensures that 1st digit after +91, there is no 0 (1-9 excepted) and the next two digit can be anything between 0-9, then a hyphen.
 
-[0-9]{3}-

Ensures that next 3 digits are anything between 0 to 9
 
[0-9]{4}

Ensure that last 4 digits are between 0 to 9

Hope this helps you!
Regards,
Jyothsna