isAlpha() (Simulated functionality)

Check if a character is a letter.

Property/method value type:Boolean primitive

This is a function normally found in the C language. However it is useful to script developers as well and may be available in some implementations as an extension to the ECMA standard functionality.

This function tests to see if a character is a letter. It will return true for any character in the following set:

A B C D E F G H I J K L M

N O P Q R S T U V W X Y Z

a b c d e f g h i j k l m

n o p q r s t u v w x y z

Strictly speaking, this function should be coded to be aware of locale specific issues. You may want to take the example simulation provided here and modify it to your own needs to support that. This is just a basic working example.

Example code:

   // Test for letters (only good up to char 127)
   function isAlpha(aChar)
   {
      myCharCode = aChar.charCodeAt(0);
   
      if(((myCharCode > 64) && (myCharCode <  91)) ||
        ((myCharCode > 96) && (myCharCode < 123)))
      {
         return true;
      }
   
      return false;
   }

See also:Character handling, Character testing, Enquiry functions, isAlnum(), Letter