CFLib.org – Common Function Library Project

IsZipCA(str)

Last updated July 15, 2005

author

Jeff Guillaume

Version: 4 | Requires: CF5 | Library: StrLib

Description:
Tests passed value to see if it is a properly formatted Canadian zip code. Does not check actual validity/existence of zip code!

Return Values:
Returns a boolean.

Example:

<cfoutput>
#YesNoFormat(IsZipCA("C9G 5B6"))#<br>
#YesNoFormat(IsZipCA("C9G5B6"))#<br>
#YesNoFormat(IsZipCA("L6V-1F3"))#<br>
#YesNoFormat(IsZipCA("R32 G2E"))#<br>
</cfoutput>

Parameters:

Name Description Required
str String to be checked. Yes

Full UDF Source:

/**
 * Tests passed value to see if it is a properly formatted Canadian zip code.
 * Peter J. Farrell (pjf@maestropublishing.com) Now checks if 1st digit if the FDA (Foward Delivery Area - 1st three digits of postal code) is one of the current 18 characters used by Canada Post as of April 2004 to signalfy a province or provincial area
 * 
 * @param str      String to be checked. (Required)
 * @return Returns a boolean. 
 * @author Jeff Guillaume (jeff@kazoomis.com) 
 * @version 4, July 15, 2005 
 */
function IsZipCA(str) {
 return REFind('^[A-CEG-NPR-TVXYa-ceg-npr-tvxy][[:digit:]][A-CEG-NPR-TVW-Za-ceg-npr-tvw-z]( |-)?[[:digit:]][A-CEG-NPR-TVW-Za-ceg-npr-tvw-z][[:digit:]]$', str);
}

Search CFLib.org


Latest Additions

Raymond Camden added
QueryDeleteRows
November 04, 2017

Leigh added
nullPad
May 11, 2016

Raymond Camden added
stripHTML
May 10, 2016

Kevin Cotton added
date2ExcelDate
May 05, 2016

Raymond Camden added
CapFirst
April 25, 2016

Created by Raymond Camden / Design by Justin Johnson