Is numeric?

Giganews Newsgroups
Subject: Is numeric?
Posted by:  Aaron DeLoach (aar…@deloachcorp.com)
Date: Mon, 28 Jul 2003

I may have cross-posted this...  :-(

I'm a VB programmer getting *way* to deep into this wonderful new JS
venture.  I looked around for a function like VBs' IsNumeric without much
success.  I had to roll my own.  Does anyone see any bugs in this?

function IsNumeric(expression) {

var nums = "0123456789";

if (expression.length==0)return(false);

for (var n=0; n < expression.length; n++){

if(nums.indexOf(expression.charAt(n))==-1)return(false);

}

return(true);

}

Replies