On Thu, Oct 6, 2011 at 11:51 AM, Andrew Scott <andr...@andyscott.id.au>wrote:
> > If this format is fixed use NumberFormat with the mask. > > > And if it's not fixed, you can use a function to spice it up. <!--------------------------------------------------------------------------------- FUNCTION FORMATS PHONE AND/OR FAX NUMBERS BASED ON LENGTH -----------------------------------------------------------------------------------> <cffunction name="FormatPhone" returnType="string"> <cfargument name="OrigNumber" type="string" required="true"> <CFSET OrigNumber = Trim(OrigNumber)> <CFSET OrigNumber = Replace(OrigNumber,Chr(10),"","ALL")> <CFSET OrigNumber = Replace(OrigNumber,Chr(13),"","ALL")> <CFIF #Len(OrigNumber)# IS 11> <cfreturn #left(OrigNumber, 1)#&"-"&#mid(OrigNumber, 2, 3)#&"-"&#mid(OrigNumber, 5, 3)#&"-"&#right(OrigNumber, 4)#> <CFELSEIF #Len(OrigNumber)# IS 10> <cfreturn "("&#left(OrigNumber, 3)#&") "&#mid(OrigNumber, 4, 3)#&"-"&#right(OrigNumber, 4)#> <CFELSEIF #Len(OrigNumber)# IS 7> <cfreturn #left(OrigNumber, 3)#&"-"&#right(OrigNumber, 4)#> <CFELSE> <cfreturn #OrigNumber#> </CFIF> </cffunction> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:347987 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm