Recommended:

  • phpclasses.org
  • jsclasses.org
  • jsmag.com
  • siteapps.com
  • View our reviews on Hot Scripts
  • JS Tutorial
  • scripts.com
  • securesignup.com




Recent Comments

Powered by Disqus




Back to articles

Javascript function to check if value is number

Here is the function, that checks if value is numeric. You can edit valid variable to add more symbols, like "." to check for float numbers or add any other allowed symbols.

function is_number(val)
{
    var valid = "0123456789";
    var number = true;
    var symbol;

    for (i = 0; i < val.length && number == true; i++) 
    { 
        symbol = val.charAt(i); 
        if (valid.indexOf(symbol) == -1) 
        {
            number = false;
        }
    }
    return number;
   
}

You may also be interested in:

Powered by BlogAlike.com

blog comments powered by Disqus