• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

XF 1.5 Disable numbers usernames for registration

Nirjonadda

Well-known member
#1
How to disable numbers usernames for registration? I want disable registration users with only numbers in username. Example: 1234

I mean the following:

Code:
Allow : Nirjonadda or nirjonadda
Allow : Nirjonadda1234 or nirjonadda1234
Disallow : 1234
I want allow numbers in usernames or any characters, but not only numbers.
 

xenfans

Well-known member
#2
You could consider using this: Admin - options - user registration - User Name Match Regular Expression
Code:
^[a-zA-Z_-]+$
This allows names with a-z, and A-Z and names with underscore _ and dashes -
This won't allow other characters, spaces, or numbers.
 

xenfans

Well-known member
#4
That does not do what the OP wanted. ;)
Ooh, I see..
OP is ok with registrations that have numbers in them, but not exclusively numbers.
He needs a regex with a negative look-ahead. I guess: suggestion, not tested
^(?![\d\s]+$)[a-zA-Z\d\s]+$
 

xenfans

Well-known member
#6
What does with this ? we need allow all in all without only numbers
letters and numbers, in pairs, seems to work
Screen Shot 2017-04-02 at 15.58.18.png

numbers and letters, seems to work
Screen Shot 2017-04-02 at 15.58.05.png
pairs of letters, seems to work
Screen Shot 2017-04-02 at 15.57.53.png

pairs of numbers, doesn't seem to work - which is what we want.
Screen Shot 2017-04-02 at 15.57.44.png

letters and numbers stuck together, works fine too
Screen Shot 2017-04-02 at 15.57.19.png

numbers and letters stuck together, works great too
Screen Shot 2017-04-02 at 15.57.06.png

all letters, yep
Screen Shot 2017-04-02 at 15.56.36.png

all numbers, nope, doesn't work - great, it's what we want
Screen Shot 2017-04-02 at 15.56.23.png


So user "bob" can register, and user "123bob" and user "bob123" but not user "1234"
 

Nirjonadda

Well-known member
#7
So user "bob" can register, and user "123bob" and user "bob123" but not user "1234"
Code:
^(?![\d\s]+$)[a-zA-Z\d\s]+$
With this code allow all any characters without only numbers?

user "bob" can register, and user "123bob" and user "bob123" but not user "1234" but Can register with special characters?
 

xenfans

Well-known member
#8
a-z,A-Z, doesn't include special characters. Just replace the query with the stuff you want to include. There are a few threads on xenforo that also handle special characters.