Thread: PHP script help
View Single Post
Old 2005-02-24, 03:07 PM   #12
Barron
You tried your best and you failed miserably. The lesson is 'never try'
 
Join Date: Oct 2004
Posts: 166
Yeah, I assumed it would only be used on text.

What I have never figured out is how to check for white space:

<?
function alphaNumeric($entered)
{
if(ereg("^[a-zA-Z0-9]*$", $entered))
{
return true;
}
}
$firstname="Jose";
$lastname="de la Cruz";
if($output=alphaNumeric($firstname) or $output=alphaNumeric($lastname)
{
echo "true";
}
?>

as a work around:

$lastname="de la Cruz";
$explode_lastname=explode(" ", $lastname);
$new_lastname=implode("", $explode_lastname);
if($output=alphaNumeric($new_lastname))
{
echo "true";
}
Barron is offline   Reply With Quote