Automatically modify phone number fields to U.S. Format

The formulas below trrim the values of a phone number to the U.S. Format and result in the following format Input validation will only occur if the value of the field is less than 12 and not 0.
Lotus Formula



TrimChars:=" abcdefghijklmnopqrstuvwxyz `~!@#$%^&*()-_+={}][:\"\',./?><";

tempNum:=@Implode(@Trim(@Explode(@LowerCase(WorkField);TrimChars) );"");

REM "tempNum now has just the numbers which can be";
REM "formatted the way you would like.";
REM "The following works for US format phone nos";
REM "It merely takes the first 10 digits and ";
REM "constructs the phone number in the format";
REM "";
REM "It ignores any characters more than 10 and";
REM "does not do anything if less than 10";

@Left(tempNum;3)+"."+ @Right(@Left(tempNum;6);3)+"."+ @Right(@Left(tempNum;10);4);


REM "Validates the phone number (US format)";
REM "Ignores if field is blank";
ErrMsg:="Please enter a valid phone number. For e.g. 123-456-7890";


intLen<12 & intLen!=0;

Posted by fbrefere001 on Tuesday May 15, 2001