moon 111 Posted March 7, 2008 Share Posted March 7, 2008 This function is evaluating false for "admin". Whats wrong? function validUsername($username) { if(preg_match("/[0-9a-zA-Z_\- ]{5, 20}/", $username)) return true; return false; } Quote Link to comment Share on other sites More sharing options...
Orio Posted March 7, 2008 Share Posted March 7, 2008 Function looks fine, maybe you are not passing the data correctly? Show the code. Orio. Quote Link to comment Share on other sites More sharing options...
effigy Posted March 7, 2008 Share Posted March 7, 2008 Remove the space in your interval. You can also clean the pattern up by using a shorthand and moving the hyphen to the beginning of the character class, thus preventing any future metacharacter confusion: /[-\w ]{5,20}/ Quote Link to comment Share on other sites More sharing options...
moon 111 Posted March 8, 2008 Author Share Posted March 8, 2008 Thanks effigy. 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.