]> cat aescling's git repositories - mastodon.git/commitdiff
[Glitch] Add HTML form validation for the registration form
authorThibG <thib@sitedethib.com>
Tue, 11 Aug 2020 21:09:13 +0000 (23:09 +0200)
committerThibaut Girka <thib@sitedethib.com>
Thu, 13 Aug 2020 20:25:33 +0000 (22:25 +0200)
Port d70c3ab4c39e642d41138ab693af77dd6c258e8c to glitch-soc

Signed-off-by: Thibaut Girka <thib@sitedethib.com>
app/javascript/flavours/glitch/packs/public.js
app/javascript/flavours/glitch/styles/forms.scss

index 58febcf5b182b18b195a06dc3a46c03b97ace4b7..8168e87da9d7664ad7e207ce09796d05da5a5fbb 100644 (file)
@@ -95,6 +95,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'));
 
index 6767c15f10cdcc47ca5aa1c2d8634fffebf21fa1..5dd312ce1483cd1dc9c66f2240480c2fc45d7df7 100644 (file)
@@ -355,7 +355,8 @@ code {
       box-shadow: none;
     }
 
-    &:focus:invalid:not(:placeholder-shown) {
+    &:focus:invalid:not(:placeholder-shown),
+    &:required:invalid:not(:placeholder-shown) {
       border-color: lighten($error-red, 12%);
     }