Updated registration page username to disallow unallowed characters

• Updated:
- registration page username to disallow unallowed characters (special characters, spaces, etc.) and rewrite if is written in that field
This commit is contained in:
Developer
2021-02-11 00:57:48 -05:00
parent 8a2f34d815
commit 538bcf21c9
4 changed files with 16 additions and 3 deletions

View File

@@ -232,6 +232,19 @@ function main ( ) {
input.readonly = oldReadOnly;
});
const handleRemoveSpecialCharactersForUsername = (e) => {
var input = e.target;
var text = input.value.replace(/[^\w\d_]/gmi, "");
if (/\s/.test(text)) {
text = text.replace(/\s/g, "");
}
input.value = text;
};
delegate(document, '#user_account_attributes_username.registration_username', 'keydown', handleRemoveSpecialCharactersForUsername);
delegate(document, '#user_account_attributes_username.registration_username', 'keyup', handleRemoveSpecialCharactersForUsername);
delegate(document, '#user_account_attributes_username.registration_username', 'change', handleRemoveSpecialCharactersForUsername);
}
loadPolyfills().then(main).catch(error => {