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.
ShowAll Questionssorted byDate Posted
Rakshith Ramachandra

# ​I have a phone field and I want add the following rules to that field.

I have a phone field and I want add the following rules to that field.
1. If the length of the field is less than 9. It should throw an error.
2. It should not accept numbers like 111-111-1111
3. It should not contain any characters (A-Z) (a-z)
4. It should not contain special characters except "("    ")"    "-"  and "+"

Can anyone help help me with this. Thanks?
Best Answer chosen by Rakshith Ramachandra
Tolga Sunar
For formatting purposes, you simply create a validation rule covering this phone field and use REGEX() function inside the formula.

I provide you a link that I have used while learning how to use REGEX() for a phone field, very easy to understand: http://www.zytrax.com/tech/web/regex.htm

For example, if I am to accept only to accept phone number formats in "+1 YXX XXXXXXX" where Y being any integer ranging from 2 to 5 and X being any integer ranging from 0 to 9. REGEX() function to ensure this format is:  NOT ( REGEX( Phone,"^\\+1 [2-5][0-9]{2} [0-9]{7}\$") )

### All Answers

Tolga Sunar
For formatting purposes, you simply create a validation rule covering this phone field and use REGEX() function inside the formula.

I provide you a link that I have used while learning how to use REGEX() for a phone field, very easy to understand: http://www.zytrax.com/tech/web/regex.htm

For example, if I am to accept only to accept phone number formats in "+1 YXX XXXXXXX" where Y being any integer ranging from 2 to 5 and X being any integer ranging from 0 to 9. REGEX() function to ensure this format is:  NOT ( REGEX( Phone,"^\\+1 [2-5][0-9]{2} [0-9]{7}\$") )

This was selected as the best answer
Rakshith Ramachandra
That helps. I'll go through the link and figure exactly what I want. Thanks.