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
-
function IsAlpha($str)
-
{
-
$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”);
-
$new = Array(“”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”);
-
if (str_replace($str, $old, $new) == “”)
-
{
-
return (true);
-
}
-
else
-
{
-
return (false);
-
}
-
}
-
function IsAlphaNumeric($str)
-
{
-
$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″);
-
$new = Array(“”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”);
-
if (str_replace($str, $old, $new) == “”)
-
{
-
return (true);
-
}
-
else
-
{
-
return (false);
-
}
-
}
function IsAlpha($str)
{
$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”);
$new = Array(“”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”);
if (str_replace($str, $old, $new) == “”)
{
return (true);
}
else
{
return (false);
}
}
function IsAlphaNumeric($str)
{
$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″);
$new = Array(“”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”);
if (str_replace($str, $old, $new) == “”)
{
return (true);
}
else
{
return (false);
}
}
Entry Filed under: Javascript. .
1 Comment Add your own
Leave a Comment
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
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