...

View Full Version : Check for spaces in string



four0four
01-26-2010, 07:12 AM
I have a form where a user can enter their first and last name.

I want to allow spaces, but if a user just enters spaces and nothing else, then it should be considered invalid.

For example:

Valid first name = Ann Marie

Invalid first name = space space

I tried the empty() function but it still doesn't work.

Thanks!

abduraooft
01-26-2010, 07:49 AM
I want to allow spaces, but if a user just enters spaces and nothing else, then it should be considered invalid.


$var=trim($var);
if(empty($var)){
//invalid
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum