CFLib.org – Common Function Library Project

OzFormatTelephone(phoneNumber)

Last updated February 26, 2004

author

Peter Tilbrook

Version: 1 | Requires: CF5 | Library: StrLib

Description:
Translates a 10 digit Australian telephone/facsimile number (either in STD or Toll Free format) into an Australian formatted telephone number.

Return Values:
Returns a string.

Example:

<cfset PhoneNumber1 = "0262842727"><!--- STD (long distance) format --->
<cfset PhoneNumber2 = "1800333999"><!--- Toll Free format --->
<cfoutput>
#PhoneNumber1# = #OzFormatTelephone(PhoneNumber1)#<br>
#PhoneNumber2# = #OzFormatTelephone(PhoneNumber2)#<br>
</cfoutput>

Parameters:

Name Description Required
phoneNumber Number to format. Yes

Full UDF Source:

/**
 * Translates a 10 digit Australian telephone/facsimile number (either in STD or Toll Free format) into an Australian formatted telephone number.
 * 
 * @param phoneNumber 	 Number to format. (Required)
 * @return Returns a string. 
 * @author Peter Tilbrook (peter@coldgen.com) 
 * @version 1, February 26, 2004 
 */
function OzFormatTelephone(PhoneNumber) {
    if (not isNumeric(PhoneNumber)) return "";
	if (left(PhoneNumber,1) eq 0) return "(" & left(PhoneNumber, 2) & ")&nbsp;" & mid(PhoneNumber, 4, 4) & "-" & right(PhoneNumber, 4);
	else if (left(PhoneNumber,1) neq 0) return left(PhoneNumber, 4) & "-" & mid(PhoneNumber, 3, 3) & "-" & right(PhoneNumber, 3);
	return "";
}
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