View comments | RSS feed
Contents > CFML Reference > ColdFusion Functions > LSIsCurrency PreviousNext

LSIsCurrency

Determines whether a string is a valid representation of a currency amount in the current locale.

True, if the parameter is formatted as a valid currency amount, including the appropriate currency indicator. Returns True for amounts in the local, international, or none currency formats.

Display and formatting functions, Decision functions, International functions

LSIsCurrency(string)

GetLocale, SetLocale, LSCurrencyFormat

ColdFusion MX: Changed formatting behavior: this function might return a different result than in earlier releases. This function uses Java standard locale formatting rules on all platforms; the results might vary depending upon the JVM; for example, Sun JVM 1.4.1 requires euro format the local currency if the current locale's country belongs to the Euro Zone.

Parameter

Description

string

A currency string or a variable that contains one.

For examples of ColdFusion code and output that shows differences between earlier ColdFusion releases and ColdFusion MX in accepting input formats and displaying output, see LSCurrencyFormat.

Note: If the locale belongs to a Euro zone country and the currency is a correctly formatted euro value for the locale, this function returns True for all JVMs, including Sun 1.3.1. As a result, with 1.3.1-compliant JVMs, the LSIsCurrency function does not ensure that LSParseCurrency returns a value. If a currency uses the older country-specific format for Euro Zone locales, the LSIsCurrency function False for newer JVMs, such as Sun 1.4.1 and True for older JVMs, such as Sun 1.3.1.

Note: To set the default display format of date, time, number, and currency values, use the SetLocale function.

<h3>LSIsCurrency Example</h3>

<cfif IsDefined("FORM.locale")>
<!--- if locale is defined, set locale to that entry --->
<cfset NewLocale = SetLocale(FORM.locale)>

<p>Is the value "<cfoutput>#FORM.myValue#</cfoutput>" 
a proper currency value for <cfoutput>#GetLocale()#</cfoutput>? <p>Answer: <cfoutput>#LSIsCurrency(FORM.myValue)#</cfoutput> </cfif> <p><form action = "LSIsCurrency.cfm"> <p>Select a locale for which you would like to check a currency value: <!--- check the current locale for server ---> <cfset serverLocale = GetLocale()>

Contents > CFML Reference > ColdFusion Functions > LSIsCurrency PreviousNext

ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | Bug Reporting

Version 6.1

Comments are no longer accepted for ColdFusion MX 6.1. ColdFusion 8 is the current version.

Comments


asherwood said on Feb 6, 2004 at 12:05 PM :
Strange behavior: for the English (US) locale, the following string returns a value of 'Yes' for the LSIsCurrency() function:

'100,000.00.00'

How is this possible with two decimal points in the currency figure?!
halL said on Feb 6, 2004 at 1:09 PM :
This issue has been logged as ColdFusion bug 54153.
asherwood said on Feb 6, 2004 at 1:35 PM :
BTW, a work around for this is to pre-process the value with the
LSParseCurrency() function.

For the string '100,000.00.00', the function will truncate the second '.00'
and return '100,000.00'. It seems to pass from left-to-right, accepting the
first decimal group and ignoring any alphanumeric data that occurs after
it. '125,000.33.66.87.90' returns '125000.33'.

Be aware, however, that this might not be the behavior you want. The user/application might supply a value in which the second decimal group is actually the desired one. Code accordingly!
AllanCliff said on Apr 20, 2004 at 3:44 AM :
LSIsCurrency() in earlier versions accepted an empty string and returned "No" as a result.

With CFMX when you test an empty string it throws an error. There fore causing major problems when moving from CF5 to CFMX.

Workaround <CFIF NOT Len(amount)><CFSET amount = 0></CFIF>
halL said on Apr 20, 2004 at 6:26 AM :
The issue noted by AllanCliff has been logged as ColdFusion bug 55149.

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/coldfusion/6.1/htmldocs/functa31.htm