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);
}
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson