> From: RADEMAKERS Tanguy [mailto:[EMAIL PROTECTED] > 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.
How about using Val() ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| 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:206924 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

