I use this regular expression to permit only usernames from 4-15 characters: /[a-zA-Z0-9][a-zA-Z0-9_.\-]{3,14}/

Though, we just had a new user registered with the name: [19 characters]@hotmail.com. Are we doing something wrong?

Comments

vm’s picture

you can set legth of usernames in adminsiter -> access rules

Schneck’s picture

This is an preg_match()-issue.

I quickly tested this pattern:

/^([a-zA-Z0-9][a-zA-Z0-9_.\-]){3,14}$/

on this online tester:

http://www.switchplane.com/utilities/preg_match-regular-expression-teste...

ans is worked as you expected. Please note the parantheses around your pattern and the ^and $ at beginning and end.

altparty’s picture

@VeryMisunderstood : Thanks, but I have an issue with limiting the username this way. This also limits the use of the password reset field. Entering an email address will give you an error because it's longer than 15 characters in many cases.

@Schneck : Thanks also. I'll give this one a try.

Greetz, Martin.

altparty’s picture

@Schneck : With the parantheses included the validation isn't working correct. I removed them and now it seems ok.

Schneck’s picture

Status: Active » Closed (fixed)