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
panderla kinnerapanderla kinnera 

phone number validation rule code

Here is the code you are looking for. 
function checkPhonefield(inputPhoneNumber)
                	var PhoneMatcher = /^[0-9-+]+$/;
                	if (!PhoneMatcher.test(inputPhoneNumber))
    					alert('Please provide valid Phone number');
    						return false;
    					return true;

Please mark it best answer it works so that it will be helpful for others

Sandeep Singhal 
Dhanya NDhanya N
Hi Panderla,

Copy this formula into your Error Condition formula of validation rule.
NOT(REGEX( Phone , "\\D*?(\\d\\D*?){10}"))
Let me know if it helps you.

DeepthiDeepthi (Salesforce Developers) 
Hi Panderla,

Please check the below validation rule for mobile number in "+91-xxx-xxx-xxxx" and starting with "7 or 8 or 9" digits.
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,
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 ( library.