From 10ff2411cf9b9328ae471863a0b81c7cfddc28d6 Mon Sep 17 00:00:00 2001 From: Sofia Yu Date: Mon, 15 Sep 2025 19:44:52 +0000 Subject: [PATCH] suggest alternative username when chosen one is taken Previously, the registration form only displayed an error when a username was already in use. This change appends a 'suffix' string to the entered username and displays it as a suggested alternative, improving the user experience. --- public/src/client/register.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/public/src/client/register.js b/public/src/client/register.js index 62dbc41..8b818c0 100644 --- a/public/src/client/register.js +++ b/public/src/client/register.js @@ -131,7 +131,20 @@ define('forum/register', [ if (results.every(obj => obj.status === 'rejected')) { showSuccess(username_notify, successIcon); } else { - showError(username_notify, '[[error:username-taken]]'); + // --- NEW: suggest an alternative username --- + const suggestion = username + 'suffix'; + translator.translate('[[error:username-taken]]', function (msg) { + username_notify.html( + msg + ' ' + + 'Try this instead: ' + + `${suggestion}` + ); + username_notify.parent() + .removeClass('register-success') + .addClass('register-danger'); + username_notify.show(); + }); + validationError = true; } callback(); @@ -139,6 +152,7 @@ define('forum/register', [ } } + function validatePassword(password, password_confirm) { const password_notify = $('#password-notify'); const password_confirm_notify = $('#password-confirm-notify');