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
Larry Van CantfortLarry Van Cantfort 

Problem I have a regex question for validation rule I have

I am trying to check to see if a field has only numbers in it. It can also be left blank. The regex formula that I have written accepts both letters and numbers and I cannot figure out what I am doing wrong. I am new to regex so please be kind.

The validation rule is:
AND( 
ISBLANK(Checking_Account_Number__c), 
NOT (REGEX(Checking_Account_Number__c, "(//[0-9]+)")) 
)

Thanks for any help.
Lalit Mistry 21Lalit Mistry 21
Hi Larry,

Use below validation instead.
NOT (REGEX(Checking_Account_Number__c, "^[0-9]*$"))

Mark this as an answer if this solves your problem.
Larry Van CantfortLarry Van Cantfort
Thanks Lalit for replying so quickly. I tried your formula and I still get the same problem. It is still accepting letters when it should only accept numbers.
Lalit Mistry 21Lalit Mistry 21
Can you confirm if you are using below formula
NOT (REGEX(Checking_Account_Number__c, "^[0-9]*$"))

and not 
AND( ISBLANK(Checking_Account_Number__c) , NOT (REGEX(Checking_Account_Number__c, "^[0-9]*$")))
Larry Van CantfortLarry Van Cantfort
Lalit,
Thanks for your help. I did have the ISBLANK in there. That fixed it.
Aman MalikAman Malik
Hi Larry,
Regex you wrote in your description seems correct except one thing i.e, '//'. So just remove it
AND( 
ISBLANK(Checking_Account_Number__c), 
NOT (REGEX(Checking_Account_Number__c, "([0-9]+)")) 
)
Thanks