pouncer Posted November 23, 2006 Share Posted November 23, 2006 Currently I have this:[code=php:0] function IsValidUsername($Username) { if ($Username && strlen($Username) > 3) return true; else return false; }[/code]How can i expand to make sure the characters entered are characters a-z or A-Z or 0-9 ? Quote Link to comment Share on other sites More sharing options...
steelmanronald06 Posted November 23, 2006 Share Posted November 23, 2006 That would be regular expressions. Of course in this instance if you just didstripslasheshtmlenetiesyou would pretty much be in the clear. Regex is mainly for email validation and things that must be string specific Quote Link to comment Share on other sites More sharing options...
trq Posted November 23, 2006 Share Posted November 23, 2006 [code=php:0]if ( preg_match('/^[a-zA-Z0-9_]{3,}$/', $Username )) return true;[/code] Quote Link to comment Share on other sites More sharing options...
pouncer Posted November 23, 2006 Author Share Posted November 23, 2006 Woah, thanks thorpe. 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.