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
MiramoMiramo 

Regex validation rule help

Hi,

I am close but trying to write a validation rule on mobile number.

Mobile should begin with a + and then the country code (below is 44) and then after the country code it should only allow the number 7 and error if any other numbers are entered.

So far I have th ebelow but its allowing any number after the +44

NOT(REGEX(MobilePhone, "^(\\+44)?[1-9]{2}[7]{1}.*?")),

example number is +44787446352

Thanks
AnudeepAnudeep (Salesforce Developers) 
Can you try the following?
 
NOT(REGEX(MobilePhone, "^(\\+44)?[7]{2}[7]{1}.*?")),

 
MiramoMiramo
Hi,

Thanks for your help but its still allowng me to save the mobile number incorrectly

Example UK mobile number is +447837726152

The validation rule must force the +44 first and then the next number must be a 7
its 11 digits long

my version allows any number after the +44
NOT(REGEX(MobilePhone, "^(\\+44)?[1-9]{2}[7]{1}.*?")),

Thanks