N.B.:
Strictly development-related issues should be discussed on the dev group:
       http://groups.google.com/group/TiddlyWikiDev/

> In testing a (user-entered) string to see if it's (potentially)
> numeric, somewhat to my surprise the string methods parseInt() and
> parseFloat() will return a number if the first part of the string
> converts successfully, ignoring trailing non-numeric characters

This seems odd indeed - though apparently that's how it's supposed to be:
https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Functions/parseInt

> implicit conversion seems to fail if it can't convert the entire
> string, and can be exploited

Note that different browsers might react differently, so you should test 
for this quirk in Firefox, IE 6-8, WebKit (Safari, Chrome) and Opera - 
not to mention mobile browsers... (Welcome to the beautiful world of web 
development.)

Therefore, even though regular expressions are often overused, it seems 
that might be the safest choice here:
     if(testStr.search(/^\d+$/) != -1) { ... }

HTH.


-- F.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/TiddlyWiki?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to