Allowing Unicode characters in username

This article describes how to allow usernames (logins) with Unicode characters (like Cyrillic, Greek, Hebrew, etc.) in your Kentico CMS website.
Please note that Unicode characters are already allowed in regular user’s name fields – First, Middle, Last and Full name – by default, so please consider if you really need this modification.

To allow usernames (logins) with Unicode characters, default validation expression has to be replaced using a web.config key "CMSUserValidationRegex" like below:

<add key="CMSUserValidationRegex" value="^[\w-.@]*$"/>

The "^[\w-.@]*$ " is just an example that allows all characters considered as word characters (letters, numbers and underscore) in Unicode set, here together with hyphen, dot and "@" symbol. You can change the expression to allow adding virtually anything in the username, but please consider writing rather safer expression to not allow any unwanted characters.
You may also want to restrict the minimum and maximum length of the username. The regular expression can be also used for this task by replacing “*” in the mentioned expression with “{minlength,maxlength}”, however validation error message won’t tell the exact reason why the entry is not accepted – like it’s too short or too long or contains forbidden characters. The default validation error message can be modified by changing the value of resource string “administration-user_new.notvalidusername”.

See also: For further details about Unicode regular expressions, please check following resources:
Unicode Regular Expressions
Analyzing Unicode Text with Regular Expressions

Applies to: Kentico CMS 4.x
Share this article on   LinkedIn

Juraj Ondrus

Hi, I am the Technical support leader at Kentico. I'm here to help you use Kentico and get as much as possible out of it.