Difference between revisions of "Validating Postal Codes"

From SmartWiki
Jump to: navigation, search
(To Only Enforce Postal Code Formats for a Particular Country)
(See Also)
Line 25: Line 25:
 
* [[Contact_and_Account_Standard_Fields#Validation|Validating Contact Standard Fields]]
 
* [[Contact_and_Account_Standard_Fields#Validation|Validating Contact Standard Fields]]
 
* [[JavaScript Validation]]
 
* [[JavaScript Validation]]
 +
* [[Country Codes]] - for the ''value'' to be used for other countries
  
 
[[Category:Validation]]
 
[[Category:Validation]]

Revision as of 16:30, 10 December 2013

You can use JavaScript Validation to ensure the postal code standard field on contact profiles conforms to a certain pattern. For example, Canadian postal codes follow the pattern of LNL NLN
Where
L = a letter
N = a number

Example: M5V 2H1

Steps

  1. Click on Global Settings
  2. Under User & Contact Settings, click on the hyperlink for User/Contact Standard Field Settings
  3. From the left-hand list of standard fields, click on the hyperlink for Zip / Postal Code
  4. In the Validation setting, enter isMatch(@value@, 'LNL NLN', true)
  5. Enter a Validation Message, such as "Postal Code must be in the format of 'A#A #A#', example: 'M5V 2H1'."
PostalCodeValidation.png
Now, when a postal code is entered, if the Postal Code is not in the specified format, the user will be prompted with the Validation Message.

To Only Enforce Postal Code Formats for a Particular Country

To only enforce the above formats for users who live in Canada, enter the following into the Validation setting:

document.frmuser.ucountry.value!="10" || isMatch(@value@, 'LNL NLN', true)

See Also