Monday, March 31, 2014

How to check if any character is alphabet or not using JavaScript.

Here is the function to do so.

//check if a character is alphabet or not
function isAlpha(aChar)
   {
      myCharCode = aChar.charCodeAt(0);
  
      if(((myCharCode > 64) && (myCharCode <  91)) ||
        ((myCharCode > 96) && (myCharCode < 123)))
      {
         return true;
      }
  
      return false;
   }

No comments:

Post a Comment