There are some more interesting problems with isNumeric and lsIsNumeric,
they can sometimes return NO even when we use a numeric value. We've
encountered with this issue several times however this is not reproducable.
Sometimes works but sometimes does not work. This problem usually occurs
when we check a session or a recordset field. We're sure the value is a
number but isNumeric/lsIsNumeric returns NO. When this problem occurs, for
instance when isNumeric(session.userId) returns NO,
lsIsNumeric(session.userId) usually returns YES. However we've encountered
that lsIsNumeric() sometimes returns NO too.

The problem exists in CF 6.x and CF 7.
Murat.

> -----Original Message-----
> From: RADEMAKERS Tanguy [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, May 17, 2005 10:03 PM
> To: CF-Talk
> Subject: interesting problem with function isNumeric and "NaN"
> 
> Hello,
> 
> I've come across an interesting problem during some form validation
> involving the function isNumeric() and the value "NaN" ("Not 
> a Number" -
> it's what js gives you when you try to use strings in math). 
> I've done a
> very quick search on Google and in the MM knowledgebase but 
> didn't find
> anything. 
> 
> Here's an example:
> 
>       <cfoutput>isNumeric("NaN")? - #isNumeric("NaN")#</cfoutput>
>       <br>
>       <cfoutput>"NaN" gt 5? - #("NaN" gt 5)#</cfoutput>
>       <br>
>       <br>
>       cfsetting myNumber = "NaN"...
>       <cfset myNumber = "NaN">
>       <br>
>       <cfoutput>isNumeric(myNumber)? -
> #isNumeric(myNumber)#</cfoutput>
>       <br>
>       <cfoutput>myNumber gt 5? - #(myNumber gt 5)#</cfoutput>
> 
> As you'll see, both isNumeric("NaN") and isNumeric(myNumber) 
> return YES,
> but "NaN" gt 5? returns NO whereas myNumber gt 5? throws a
> coldfusion.runtime.Cast$NumberConversionException - The value "NaN"
> cannot be converted to a number. This is causing me some problems
> because i have code that looks like:
> 
>       <cfif (not(isNumeric(myField)) or (myField gt
> ListGetAt(rule,2,":")))>
> 
> I wrote a quick and dirty isNaN() UDF (like the native one is js) so i
> can fix the immediate problem, but i can't help thinking that i'm
> missing something obvious.
> 
> This is on CFMX 6 and my local copy of CFMX 7. 
> 
> /t
> 
> 
> 
> 
> 
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:206926
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to