[solved] validating a post (checking for spaces in string)
Posted: Wed Jul 13, 2005 7:14 am
Hi all,
Just wondering what function I should be using to check if a username has spaces in it when a user registers on a form?
I've got this for the invalid characters:
but nothing for spaces it seems (I don't understand regular expressions sorry, no matter how many times I go over it, I AM an artist after all, just trying to figure this stuff out
).
I'd appreciate any direction.
Thanks,
Rob
Just wondering what function I should be using to check if a username has spaces in it when a user registers on a form?
I've got this for the invalid characters:
Code: Select all
function check_username($str)
{
//returns 1 if valid email, 0 if not
/* if(ereg("^.+@.+\..+$", $str))
return 1;
else
return 0; */
if (preg_match('/[a-z]+/i',$str))
{
return "1";
}
else
{
return "0";
}
}I'd appreciate any direction.
Thanks,
Rob