Skip to main content link. Accesskey S
  • Log In
  • Help
  • IBM Logo
  • IBM Forms wiki
  • All Wikis
  • All Forums
  • ANNOUNCEMENT: This site is scheduled for removal. (REVISED DATE) READ MORE...
  • Home
  • Product Documentation
  • Community Articles
  • Learning Center
  • IBM Redbooks
  • API Documentation
Search
Community Articles > Best Practices for Form Design > Field Formatting Best Practices > Formatting postal codes
  • New Article
  • Share Show Menu▼
  • Subscribe Show Menu▼

About the Original Author

Click to view profileAdam Kozyniak
Contribution Summary:
  • Articles authored: 115
  • Articles edited: 113
  • Comments Posted: 0

Recent articles by this author

Specify type for public data

When creating or marking data as public in the Designer, specify the data type using a Model Item Property. Example Below are some examples of Model Item Property data types: xforms:bind nodeset"instance('INSTANCE1')PAGE1ffloat" type"xsd:float" xforms:bind xforms:bind ...

Do not cross reference types when mapping data

When mapping data, do not crossreference data types. Data should be mapped type to type, for example string to string rather than string to integer.

Do not create submission or cancellation buttons for forms used in FileNet

A Lotus form imported into FileNet is submitted using the SaveLaunchComplete buttons located in the FileNet toolbar. The form itself should contain no submission or cancellation buttons. When creating a form for FileNet using the Designer, do not insert submission or cancellation buttons into ...

Toolbar differences between Lotus Forms and FileNet

When rendering forms, toolbar hotkey accessibility differs between Lotus Forms and FileNet. Lotus Forms accessibility also varies based on the browser. FileNet eForms use Java Script key listeners, which means toolbar hotkeys will always be Ctrl + Alt + key. Lotus Forms forms use the HTML based ...

Use ufv_settings to hide Lotus Forms menu

When a form is created for use in FileNet, use the ufvsettings in the Designer to turn off the menu toolbar. Forms rendered in FileNet use the FileNet toolbar to control form submission. The menu used by Lotus Forms is not required and should be turned off. Example ufvsettings menu ...
Community articleFormatting postal codes
Added by Adam Kozyniak | Edited by IBM contributorDeanna Drschiwiski on September 8, 2008 | Version 7
expanded Abstract
collapsed Abstract
Postal codes (also known as post codes or ZIP codes) are a series of characters appended to a postal address for the purpose of sorting mail. Many countries use 4, 5, 6, or 9 digit numeric strings, while others use both numbers and letters. In your form, you may want to accept a wide range of valid postal code formats while filtering invalid ones. You can do this by defining the field’s presentation format and providing input constraints.
Tags: field, format, postal code, zip code
 

Postal codes (also known as post codes or ZIP codes) are a series of characters appended to a postal address for the purpose of sorting mail. Most countries use 4, 5, 6, or 9 digit numeric strings, while others use both numbers and letters. In your form, you may want to accept a wide range of valid postal code formats while filtering invalid ones. You can do this by defining the field’s presentation format and providing input constraints.

Input Constraints


In particular, you must specify the patterns that the postal code fields may accept. For example, to specify a Canadian postal code (two sets of three alternating alphanumeric characters, such as V9A 1G2) you would create a pattern that allows:
  • a letter
  • a number
  • a letter
  • an optional space
  • a number
  • a letter
  • a number

You must use a Unix-style regular expression to specify this pattern. For example, the following regular expression creates the pattern described above:

([A-Za-z]{1}[0-9]{1}[A-Za-z]{1})\s?([0-9]{1}[A-Za-z]{1}[0-9]{1})

A field formatted with only this expression would accept user input formatted in only two ways:
  • x#x #x#
  • x#x#x#

To add additional postal code styles, you need to add additional acceptable patterns. For example, to add 4, 5, or 6 character digit strings, or a 9 digit string that may contain a dash, you would add the following patterns:

(\d{4})
(\d{5})
(\d{6})
(\d{5})-?(\d{4})

Presentation


For every pattern you create as an input constraint, you must have a corresponding presentation patternref. The patternref allows you to specify how the user’s input is displayed in the form. If there are multiple patterns, the first patternref corresponds to the first pattern, the second patternref corresponds to the second pattern, and so on. You must use a Unix-style regular expression to specify this patternref. The follow example shows the patternrefs for the 6 character alphanumeric code, the 4, 5, and 6 digit codes, and the 9 digit code that contains a dash:

$1 $2
$1
$1
$1
$1-$2

Note that the patternref for the 4, 5, and 6 digit codes is exactly the same (indicating a single string). However, each must be listed separately to ensure they correspond with the correct input constraint pattern.

Examples


The following code sample shows how to accept multiple postal code formats and allow them to display in the format chosen by the user. This example also uses casetype to ensure that any letters are displayed as upper case:

<field sid="FIELD4">
 <label>Postal/ZIP code</label>
 <format>
    <datatype>string</datatype>
    <constraints>
       <patterns>
          <pattern>([A-Za-z]{1}[0-9]{1}[A-Za-z]{1})\s?([0-9]{1}[A-Za-z]
            {1}[0-9]{1})</pattern>
          <pattern>(\d{4})</pattern>
          <pattern>(\d{5})</pattern>
          <pattern>(\d{6})</pattern>
          <pattern>(\d{5})-?(\d{4})</pattern>
       </patterns>
    </constraints>
    <presentation>
       <patternrefs>
          <patternref>$1 $2</patternref>
          <patternref>$1</patternref>
          <patternref>$1</patternref>
          <patternref>$1</patternref>
          <patternref>$1-$2</patternref>
       </patternrefs>
       <casetype>upper</casetype>
    </presentation>
 </format>
 <value></value>
</field>

Exceptions to this practice


There are no exceptions to this practice.
expanded Attachments (0)
collapsed Attachments (0)
expanded Versions (9)
collapsed Versions (9)
Version Comparison     
VersionDateChanged by              Summary of changes
9Dec 2, 2010, 1:10:42 PMJack Mitchell  IBM contributor
8Mar 31, 2010, 4:54:43 PMDeanna Drschiwiski  IBM contributor
This version (7)Sep 8, 2008, 1:20:27 PMDeanna Drschiwiski  IBM contributor
6Jul 4, 2008, 4:21:28 PMDeanna Drschiwiski  IBM contributor
5Jul 4, 2008, 4:21:26 PMDeanna Drschiwiski  IBM contributor
4Jun 12, 2008, 2:22:14 PMAdam Kozyniak  IBM contributor
3Jun 10, 2008, 6:49:44 PMAdam Kozyniak  IBM contributor
2Jun 9, 2008, 12:54:19 PMAdam Kozyniak  IBM contributor
1Jun 9, 2008, 12:44:49 PMAdam Kozyniak  IBM contributor
Copy and paste this wiki markup to link to this article from another article in this wiki.
Go ElsewhereStay ConnectedHelpAbout
  • IBM Collaboration Solutions wikis
  • IBM developerWorks
  • IBM Software support
  • Twitter LinkIBMSocialBizUX on Twitter
  • FacebookIBMSocialBizUX on Facebook
  • ForumsLotus product forums
  • BlogsIBM Social Business UX blog
  • Community LinkThe Social Lounge
  • Wiki Help
  • Forgot user name/password
  • Wiki design feedback
  • Content feedback
  • About the wiki
  • About IBM
  • Privacy
  • Accessibility
  • IBM Terms of use
  • Wiki terms of use