Validation Formula For Phone Numbers

Takes phone numbers as entered and reformat them in a standard USA format.
REM "**** Define Standard Variables ***";
REM;
@If(Phone="";@Return("");"");
Phone0 := @ReplaceSubstring (Phone; "("; "");
Phone2 := @ReplaceSubstring (Phone0; ")"; "");
Phone3 := @ReplaceSubstring (Phone2; "-"; "");
Phone4 := @ReplaceSubstring (Phone3; "/"; "");
Phone5 := @ReplaceSubstring (Phone4; " "; "");
Phone6 := @ReplaceSubstring (Phone5; "_"; "");
Phone7 := @ReplaceSubstring (Phone6; "="; "");
LengthPhone := @Length (Phone7);
Phone8:= @If(LengthPhone > 10 ; @Right (Phone7; 10); Phone7);
nofrillphone := @Trim(Phone8);
REM "Set default area code if none intered to 714";
area := @If(LengthPhone = 7;"714";@Left(nofrillphone;3));
other := @If(LengthPhone = 7;nofrillphone;@Right(nofrillphone; area));
pre := @Left(other; 3);
suffix := @Right(other;4);
PhoneLen := (LengthPhone -10);
dialPre := @If(LengthPhone > 10; @Left(Phone7;PhoneLen); "");
@If(LengthPhone>10; Phone; DialPre + "(" + area + ") " + pre + "-" + suffix)
This was first published in November 2000

Dig deeper on Domino Resources - Part 6

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchEnterpriseLinux

SearchDataCenter

SearchExchange

SearchContentManagement

Close