Author Topic: Javascript IsNumeric Function  (Read 6115 times)

Offline admin

  • Administrator
  • Sr. Member
  • *****
  • Posts: 296
    • View Profile
Javascript IsNumeric Function
« on: September 07, 2009, 11:22:17 AM »
In Javascript there is no IsNumeric function so you can use this function to check numerical values:
Code: [Select]
function IsNumeric(sText)
{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++)
      {
      Char = sText.charAt(i);
      if (ValidChars.indexOf(Char) == -1)
         {
         IsNumber = false;
         break;
         }
      }
   return IsNumber;
   
   }