JRS: In article <jv********************@eatel.net>, seen in
news:comp.lang.javascript, Aaron DeLoach <aa***@deloachcorp.com> posted
at Mon, 28 Jul 2003 22:14:23 :-
I may have cross-posted this... :-(
You did not; perhaps you mean multi-posted.
I looked around for a function like VBs' IsNumeric without much
success.
Without an accurate knowledge of the VB function it is difficult to
emulate it reliably. For example. what about an empty string?
function IsNumeric(S) { return S > '' && ! isNaN(S) }
seems reasonable. But, for me, it accepts 1e9999 - Infinity is a
number.
function IsNumeric(S) { return S > '' && isFinite(S) }
However, in any practical application, the permissible input is likely
to be more limited; use a RegExp to test for, say, 1..5 decimal digits
preceded by sign or space.
OK = /^[-+ ]?\d{1,5}$/.test(S)
--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> JS maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/JS/&c., FAQ topics, links.