about summary refs log tree commit diff
path: root/app/javascript/packs
diff options
context:
space:
mode:
authorThibG <thib@sitedethib.com>2020-08-11 23:09:13 +0200
committerGitHub <noreply@github.com>2020-08-11 23:09:13 +0200
commitd70c3ab4c39e642d41138ab693af77dd6c258e8c (patch)
treeeb25abb98eff9dd6a8eba7432b369b89a38c3d17 /app/javascript/packs
parentef057584fd2714d94666f9ffef4aa89147eda72c (diff)
Add HTML form validation for the registration form (#14560)
* Add HTML-level validation of username in sign-up form

* Make required fields with incorrect values more visible

* Enable HTML form validation for the registration form

* Mark agreement checkbox as required client-side

* Add minimum length to password

* Add client-side password confirmation validation
Diffstat (limited to 'app/javascript/packs')
-rw-r--r--app/javascript/packs/public.js10
1 files changed, 10 insertions, 0 deletions
diff --git a/app/javascript/packs/public.js b/app/javascript/packs/public.js
index 08cc662e6..777182b7f 100644
--- a/app/javascript/packs/public.js
+++ b/app/javascript/packs/public.js
@@ -116,6 +116,16 @@ function main() {
       new Rellax('.parallax', { speed: -1 });
     }
 
+    delegate(document, '#registration_user_password_confirmation,#registration_user_password', 'input', () => {
+      const password = document.getElementById('registration_user_password');
+      const confirmation = document.getElementById('registration_user_password_confirmation');
+      if (password.value && password.value !== confirmation.value) {
+        confirmation.setCustomValidity((new IntlMessageFormat(messages['password_confirmation.mismatching'] || 'Password confirmation does not match', locale)).format());
+      } else {
+        confirmation.setCustomValidity('');
+      }
+    });
+
     delegate(document, '.custom-emoji', 'mouseover', getEmojiAnimationHandler('data-original'));
     delegate(document, '.custom-emoji', 'mouseout', getEmojiAnimationHandler('data-static'));