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
AiyazAiyaz 

Create one validation rule for 3 fields (Phone, Fax and Mobile)

Hello all, I am new on this board!
 
I am having difficulties creating a validation rule to apply to the three fields mentioned in the title.
 
The validation rule to apply is:
 
Phone, Fax and Mobile number fields should start with "+" or they can be left blank.
I only have it working for one field.  Below is the formula:
 
AND (
 
(LEFT(Phone, 1) <> ""),
(LEFT(Phone, 1) <> "+") )
 
)
 
This is just for the phone field.  I cannot seem to apply this to the other 2 fields (mobile and fax).
 
Does anyone have any input on what I can do and is there a way I can avoid having to create validations for each 3 fields as I would rather have just have a single validation rule to check all three fields?
 
Thanks in advance.


Message Edited by Aiyaz on 10-29-2008 02:10 PM

Message Edited by Aiyaz on 10-29-2008 02:11 PM
JakesterJakester
Hi Aiyaz,

First, a quick tip: use the SRC button before pasting in code. That will prevent semicolons and parenthesis from becoming smiley faces.

Second, you can't create a generic function-like validation rule then apply it to different fields. But, you can easily copy and paste your code and swap out the phone field for the fax field. The nice thing about this approach is that you can customize the error message and place it in the right spot (next to the fax field).

Finally, another option is to combine all 3 rules into one by adding an Or() statement. The drawback to this approach is you have to put the validation error message at the top of the page and just say "Check the phone, fax, and mobile fields".
AiyazAiyaz

Hi Jake,

 

Thanks, actually late last night I did exactly what you said which was use the OR expression, but yes, you're correct you have to put the error message at the top else it will only show under the field for which you created the Validation Rule under.

 

Thanks for the advise!!  Below is the code that worked for me:

 

Code:
OR( 

AND( 
LEFT ( Phone ,1) <> "", 
LEFT ( Phone ,1) <> "+" 
), 

AND( 
LEFT ( Fax ,1) <> "", 
LEFT ( Fax ,1) <> "+" 
), 

AND( 
LEFT ( MobilePhone ,1) <> "", 
LEFT ( MobilePhone ,1) <> "+" 
) 

)


 

JakesterJakester
Strong work! :smileytongue: