XF 2.2 How to disable numbers usernames

Sanmu

Active member
I found many people use their phone number or id number to register website.

How can I stop this?

Allow
Brogan

Allow
Brogan1234

Disallow
1234
111
15829322998
 
I think the following threads will help you.



You may use regex,

For example: /^[a-z0-9À-ÿ_\-\ ]+$/i

a-z any letter
0-9 any digits/numbers
À-ÿ special characters (diacritics)
_ underscore
\-\ hyphen
 
Setup > Options > User registration > Username match regular expression

This will largely depend on what characters you do want to allow, but for letters and some special characters you could use:
/^[a-zA-Z!&^\-.*_\s]+$/i

There's a number of different expressions to achieve different results, Google search RegEx Tutorial.
 
I don't know how to code.

I searched a lot and tested some expressions.

I found this one is what I need for numbers and letters:
Code:
/^[a-z0-9\s]+$/i

This one is what I need for Chinese language
Code:
/^(?:[^\u3400-\u4DB5\u4E00-\u9FEA\uFA0E\uFA0F\uFA11\uFA13\uFA14\uFA1F\uFA21\uFA23\uFA24\uFA27-\uFA29]|[^\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][^\uDC00-\uDFFF]|\uD869[^\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[^\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[^\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[^\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[^\uDC00-\uDFE0])+$/

So what I need is to combine these two functions, allow both of them to register on my website.

How can I combine these two regular expressions? I don't want someone to use only numbers register on website.
 
Last edited:
Top Bottom