1

this is my validation rule but the thing is if i left blank phone and save it record its fire validation rule but my concern is only number allowed that is working fine but if person dont have phone he can left blank. how to allowed blank

OR( 
    OR( 
        LEN( Phone ) <= 9 ,
        LEN( Phone ) >= 13 
    ), 
    NOT( 
        OR( 
            REGEX(Phone, "[0-9 ]+"), 
            REGEX(Phone, "\\+[0-9 ]+")
        ) 
    ) 
)

3 Answers 3

2

You say that the length of the phonenumber can't be lower than 9. That is the problem. You should combine that with the 0. Maybe like this:

OR( 
        AND(
           LEN( Phone ) <= 9 ,
           LEN( Phone ) <> 0
        ),
        LEN( Phone ) >= 13 
    ),
4
  • is this blank value can be accepted. i need blank value allowed Feb 3, 2017 at 9:45
  • if i am entering 3 digit or 4 digit its throw error. how can is also accepteable and character not allowed Feb 3, 2017 at 9:50
  • Why don't you test it? Than you know of it works for blank value ;) . If this does not work you can use 'ISBLANK()'-function. Don't forget to add not. NOT(ISBLANK(Phone))
    – nesnaj713
    Feb 3, 2017 at 9:52
  • i have tried this now its worked AND(NOT(REGEX(Phone,'\\d*')), NOT(REGEX(Phone,'\(\\d{3}\) \\d{3}-\\d{4}'))) Feb 3, 2017 at 9:56
1

Try this

AND(OR( 
    OR( 
        LEN( Phone ) <= 9 ,
        LEN( Phone ) >= 13 
    ), 
    NOT( 
        OR( 
            REGEX(Phone, "[0-9 ]+"), 
            REGEX(Phone, "\\+[0-9 ]+")
        ) 
    ) 
),NOT(ISBLANK(Phone)))
1

Modify your regex as per requirement and replace with below regex.

Given regex is for pattern '(555) 555-5555'.

IF(NOT(ISBLANK(Phone)),NOT(REGEX(Phone, "[0-9+\\-\\(\\)\\s]{14}")),false)

This validation formula also save blank field for Phone type field. If you still get error then you have to change field's page property in edit page layout and uncheck the field property 'Required'.

Uncheck 'Required' in Edit Page Layout :

Set in Edit Page Layout

You must log in to answer this question.

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