CFLib.org – Common Function Library Project

isPostalCodeDK(str)

Last updated October 06, 2005

author

Peter J. Farrell

Version: 1 | Requires: CF5 | Library: StrLib

Description:
Check if postal code is a valid postal code of Denmark. Does not check if the postal actually exsists, but if it meets the format. Regex is case insensitive.

Return Values:
Returns a string.

Example:

<cfoutput>
#isPostalCodeDK("DK-0111")# (false because first numeric is 0)<br/>
#isPostalCodeDK("CH-9999")# (false)<br/>
#isPostalCodeDK("DK-1999")# (true)
</cfoutput>

Parameters:

Name Description Required
str String to check. Yes

Full UDF Source:

/**
 * Checks if valid postal code of Denmark.
 * 
 * @param str      String to check. (Required)
 * @return Returns a string. 
 * @author Peter J. Farrell (pjf@maestropublishing.com) 
 * @version 1, October 6, 2005 
 */
function isPostalCodeDK(str) {
    // The first numeric of the postal codes cannot start with 0
    return REFind("^[D-d][K-k]( |-)?[1-9]{1}[[:digit:]]{3}$", arguments.str) gte 1;
}

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