Format ZIP and ZIP+4 Codes

From HotDocs Wiki

Jump to: navigation, search

You can use one of two text patterns to automatically format a ZIP Code. Use 99999 when you want only the first five digits of the ZIP code, or use 99999-9999 when you want the full ZIP+4 Code. However, if you use the ZIP+4 format, users often do not know the final four digits of the ZIP code. If these digits are left unanswered, HotDocs includes spaces in their place when the number is merged into your document. For example, if the user enters only five digits, the assembled document could look like this:

 The office is located at 123 Spruce Way, Clearfield, RI 12345-    .

Using the following computation, you can prevent HotDocs from including the hyphen and spaces for unanswered digits in a ZIP code. The computation first determines if the last four digits are answered. If they are not answered, the computation returns only the first five digits of the ZIP code. Otherwise, the computation returns the full ZIP+4 code.

Example

"" 
IF MID( Text Var, 7, 4 ) = "    "
  FIRST( Text Var, 5 )
ELSE
  Text Var
END IF

Text Var Any Text variable for a ZIP+4 code that uses the 99999-9999 pattern.