You need to sign in to do that
Don't have an account?

Formula to count the number of digits in a string
I'm trying to create a validation rule for Phone field in Salesforce. It accepts any number of digits. I want to limit it between 9-13. So I've to write up a validaition that does that. Remember I'm trying to count the number of 'DIGITS' only.
So I can't use OR(LEN(Phone) < 9, LEN(Phone) > 13). LEN counts the spaces, brackets etc.
For eg: (832) 999-9999 has 10 digits but 14 characters. LEN returns 14 not 10
So I can't use OR(LEN(Phone) < 9, LEN(Phone) > 13). LEN counts the spaces, brackets etc.
For eg: (832) 999-9999 has 10 digits but 14 characters. LEN returns 14 not 10
OR(
LEN(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(Phone," ",""),"-",""),"(",""),")","")) < 9,
LEN(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(Phone," ",""),"-",""),"(",""),")","")) > 13)
If someone knows a better solution. Please go ahead
All Answers
OR(
LEN(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(Phone," ",""),"-",""),"(",""),")","")) < 9,
LEN(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(Phone," ",""),"-",""),"(",""),")","")) > 13)
If someone knows a better solution. Please go ahead