Jessica Posted December 29, 2006 Share Posted December 29, 2006 [code]if(!preg_match("/^[A-Za-z.]+$/", $this->username)){ $valid = 0;}else{ $valid = 1;}[/code]I also want to allow the - and a single space.Help? Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted December 29, 2006 Share Posted December 29, 2006 just add them in the character range:[code][A-Za-z.-\s][/code] Quote Link to comment Share on other sites More sharing options...
c4onastick Posted December 31, 2006 Share Posted December 31, 2006 Actually if you want to include the '-' character it needs to appear first in a character class (or escape it, since it has special meaning inside the class, as in 'A-Z').[code]if(!preg_match("/^[-A-Za-z.\s]+$/", $this->username)){ $valid = 0;}else{ $valid = 1;}[/code] Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 1, 2007 Author Share Posted January 1, 2007 Thanks! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.