ctype_alpha but allow spaces(php)
        Posted  
        
            by helloo
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by helloo
        
        
        
        Published on 2010-05-29T22:52:23Z
        Indexed on 
            2010/05/29
            23:12 UTC
        
        
        Read the original article
        Hit count: 201
        
php5
I was wondering if one can allow spaces in a textfield when checking it with ctype_alpha. Since ctype_alpha only allows alphabetical letters, I don't know how to let the user enter space in the field. I did try using ctype_space but that didn't work. I simply want the user to be able to type only alphabets and they have a choice to include spaces if they "wish." I hope I will not have to use regexp as I am very new to all of this and hope to learn it at a later date. Below is some of the code...Thank you.
elseif (!ctype_alpha($fname))
   {
echo "Your name may only contain alphabetical letters";
   }
        © Stack Overflow or respective owner