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
Megan27Megan27 

Validation Rule to prevent dashes, slashes & spaces.

Hi Everyone!  

   I am trying to create a validation rule for a SSN field. We want to make sure users only are allowed to save numbers. No slashes, dashes, or spaces and if they don't add all 10 digits they get an error message. Any ideas? Thanks. 
SalesFORCE_enFORCErSalesFORCE_enFORCEr
Try this
OR( 
LEN(SSN__c)>10, 
LEN(SSN__c)<10, 
CONTAINS(SSN__c, "/"), 
CONTAINS(SSN__c, " "), 
CONTAINS(SSN__c, "-") 
)
Megan27Megan27
That worked. Thank you! 
Parker EdelmannParker Edelmann
Here's another way to write it:
LEN(SSN__c) != 10 || !ISNUMBER(SSN__c)
"LEN(SSN__c) != 10" checks if the length of the SSN is equal to 10 or not. "||" is the OR operator, and ISNUMBER checks if SSN is a number, or has non-numeric characters.
ET 10ET 10
 This works for a similar gituation I have, however, it does not allow for null or blank values without hitting the rule
ET 10ET 10
This worked for me.

AND(
NOT(ISBLANK(HomePhone)),
OR(
LEN(HomePhone) != 10,
!ISNUMBER(HomePhone)))