0

I wanted to write a validation rule for default Phone field.

AND( 
    NOT(ISBLANK( Phone )), 
    NOT(ISNUMBER( Phone )) 
)

it works fine but allows only 9 digits. What could be the problem? When i Deactivate this validation rule, it accepts more than 10 digits or alphabets. Why is the Number restriction enforced?

2
  • What error are you getting when you add more than 9 digits? Jan 26, 2016 at 22:54
  • Validation error which i mentioned in the validation rule Jan 26, 2016 at 23:02

1 Answer 1

2

Ten digit numbers are automatically reformatted as '(###) ###-####', which means that ISNUMBER will return false (because it has spaces, parentheses, and a hyphen). Also, when you see the documentation, you'll see it also supports numbers like 2e2 or 123.123, which are both numbers, but not phone numbers.

So, what you're probably looking for, for a start, is two specific patterns that will match US and other numbers:

AND(NOT(REGEX(Phone,'\\d*')), NOT(REGEX(Phone,'\\(\\d{3}\\) \\d{3}-\\d{4}')))

You'll want to experiment with REGEX to determine which rule(s) you'd like to follow.

1
  • Thanks It is accepting < 10 digits and >10 digits. I figured this is better. IF( ISBLANK(Phone) , false , NOT( REGEX( Phone,"(\\D?[0-9]{3}\\D?)[\\s][0-9]{3}-[0-9]{4}")) ) Jan 27, 2016 at 0:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .