Is string alpha only?

November 24, 2007

Use the function IsAlpha to determine if a string is alpha only and use IsAlphaNumeric to find if it is alphanumeric.  

Snippet

  1. function IsAlpha($str)

  2. {

  3.    $old = Array(“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”);

  4.    $new = Array(“”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”);

  5.    if (str_replace($str, $old, $new) == “”)

  6.    {

  7.       return (true);

  8.    }

  9.    else

  10.    {

  11.       return (false);

  12.    }

  13. }

  14. function IsAlphaNumeric($str)

  15. {

  16.    $old = Array(“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”, “1″, “2″, “3″, “4″, “5″, “6″, “7″, “8″, “9″, “0″);

  17.    $new = Array(“”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”);

  18.    if (str_replace($str, $old, $new) == “”)

  19.    {

  20.       return (true);

  21.    }

  22.    else

  23.    {

  24.       return (false);

  25.    }

  26. }

Entry Filed under: Javascript. .

1 Comment Add your own

  • 1. cathern  |  December 12, 2007 at 10:39 pm

    I have considerably improved my credit score recently and have been elevated for FICO B rating. However, for Transunion and Experian, they are now using Vantage instead, which lowers me to a C cat. Do you know which scoring system do they use at

    free balance transfer credit

    Reply

Leave a Comment

Required

Required, hidden

Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Trackback this post  |  Subscribe to the comments via RSS Feed


Categories

Category Cloud

.Net Business HTML & CSS & DOM Javascript PHP Tool

Tags

.Net ADO.NET ajax Business Javascript Oracle ADO.NET Subversion .Net Subversion SVN Source VB.Net

Recent Posts

Archives

Blogroll

Recent Comments

Asaduzzaman Arif on Encrypt/Decrypt string VB…
Pranav on Encrypt/Decrypt string VB…
ntcnet on Encrypt/Decrypt string VB…
Elena on Encrypt/Decrypt string VB…
Elena on Encrypt/Decrypt string VB…

Twitter