CFLib.org – Common Function Library Project

formatUKPostcode(str)

Last updated July 27, 2012

author

Steve Chandler

Version: 1 | Requires: CF5 | Library: StrLib

Description:
Formats a string to become a valid UK postcode

Return Values:
Returns a string

Example:

#formatUKPostcode(form.postcode)#

Parameters:

Name Description Required
str String to format Yes

Full UDF Source:

/**
 * Formats a string to become a valid UK postcode
 * version 1.0 by Steve Chandler
 * 
 * @param str 	 String to format (Required)
 * @return Returns a string 
 * @author Steve Chandler (cflib@chandler.it) 
 * @version 1, July 27, 2012 
 */
function formatUKPostcode(str){
	var strPostcode = ucase(trim(replaceNoCase(str,' ','','all')));
	return left(strPostcode,len(strPostcode)-3) & ' ' & right(strPostcode,3);
}
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