Hi. regex hurts my brain. This simple function will validate a username.
1. between 4 and 20 characters
2. can only be numbers or letters
function f_validate_username($username) {
$normal = "^([a-zA-Z0-9]{4,20})$";
if (eregi($normal, $username)) {
return true;
}
else {
return false;
}
}
What I want to add, but can't figure out... is how to check to make sure it doesn't START with a number.
matches: ab1cde , aBcd1, aaaa, a1111
doesn't match: 1acbd
Thanks :)