[TikiWiki-commits] [Git][tikiwiki/tiki][master] [ENH] Improve username validation UX on registration page

Benoit Grégoire (@benoitg) via TikiWiki-cvs <[email protected]>
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <698f8fd3eacff_3b18586c32340@gitlab-sidekiq-low-urgency-cpu-bound-v2-7b68dd745d-v9pv8.mail>

Benoit Grégoire pushed to branch master at Tiki Wiki CMS Groupware / Tiki


Commits:
2dca99ee by Olivier Kango at 2026-02-13T20:47:50+00:00
[ENH] Improve username validation UX on registration page
---
* [FIX] Show configured username_pattern in validation error

* keep the server-side message strictly about spaces

* [FIX] Improve username validation feedback

* [FIX] Clarify username whitespace validation message

* [FIX] Clarify username validation error messages and remove comment

* [ENH] Improve username validation UX on registration page

See merge request tikiwiki/tiki!9564

- - - - -


2 changed files:

- lib/validators/validator_username.php
- templates/user_registration.tpl


Changes:

=====================================
lib/validators/validator_username.php
=====================================
@@ -19,12 +19,12 @@ function validator_username($input, $parameter = '', $message = '')
         if ($userlib->user_exists($input)) {
             return tra("User already exists");
         }
-        if (! empty($prefs['username_pattern']) && ! preg_match($prefs['username_pattern'], $input)) {
-            return tra("Invalid character combination for username");
-        }
         if (! preg_match($userlib::USERNAME_MANDATORY_VALIDATION_PATTERN, $input)) {
             return tra("Username cannot contain any spaces");
         }
+        if (! empty($prefs['username_pattern']) && ! preg_match($prefs['username_pattern'], $input)) {
+            return tr("Username must match the configured format: %0", $prefs['username_pattern']);
+        }
         if (strtolower($input) == 'anonymous' || strtolower($input) == 'registered') {
             return tra("Invalid username");
         }


=====================================
templates/user_registration.tpl
=====================================
@@ -48,6 +48,20 @@
                     $form.find('button[type="submit"], .registerSubmit').prop('disabled', state === true).toggleClass('disabled', state === true);
                 }
 
+                var isFormValid = true;
+                if (typeof $form.validate === 'function') {
+                    if (!$form.data('validator')) {
+                        $form.validate();
+                    }
+                    if (!$form.valid()) {
+                        isFormValid = false;
+                    }
+                }
+                
+                if (!isFormValid) {
+                    return;
+                }
+
                 setSubmitting(true);
 
                 var isWebauthnEnabled = "{{$prefs.auth_webauthn_enabled}}";



View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/2dca99eead96b2bd66975b7a70abafb5236062f2

-- 
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/2dca99eead96b2bd66975b7a70abafb5236062f2
You're receiving this email because of your account on gitlab.com.

_______________________________________________
TikiWiki-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.