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
venkateshyadav1243venkateshyadav1243 

Validation rule for phone numer

Hi

i need validation rule for phone number

 

it should be number it will not allow string and special character and it can be more than 10 digits how can i write the validation rule.

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

i write one it accepting only 10 i need it can accept any number means more than 10 or less than 10.

 

 

Can any one help me.

 

Regards

venkatesh.

Vinita_SFDCVinita_SFDC

Hi,

 

You can simply achieve this using functions ISBLANK and ISNUMBER in your validation rule. Ex:

 

OR(ISBLANK(MobilePhone), NOT(ISNUMBER(MobilePhone)))

@anilbathula@@anilbathula@
Hi venkateshyadav,

Try this validation rule :-

IF(
ISBLANK( MobilePhone ) , false , NOT(REGEX(MobilePhone, "\\D*?(\\d\\D*?){1,20}")))

I have kept a limit of 1-20 so you can enter upto 20 digits.
so now it will allow number less than 10 and more than 10 upto 20 digits.
Nithya@metasts.comNithya@metasts.com

Hi,

 

Use the below Validation Rule.It won't accept String and Special Characters.

It accept numbers more than or less than 10 digits.

 

NOT(REGEX(  mobile__c  ,"^[0-9]*$"))

 

Please mark my answer as a solution, it its correct.Dont forget to give kudos if its working perfectly.

 

Regards,

   Nithya kalyani.C / Salesforce Developer

 

 

 

Vijay NagarathinamVijay Nagarathinam

Hi,

 

This should do it for you if your goal is to have the standard US format     (555)555-5555
 
Use the code
 
NOT(REGEX(metasts__mobile_no__c , "\\D*?(\\d\\D*?){10}"))