diff options
author | ThibG <thib@sitedethib.com> | 2020-08-12 12:11:15 +0200 |
---|---|---|
committer | Starfall <us@starfall.systems> | 2020-08-25 13:36:48 -0500 |
commit | d1cf10154133d63a770fe263d788908b04571513 (patch) | |
tree | 1d32f8ab0acadbde1b0ba6af5b7e6ffda4015116 /app/javascript/packs | |
parent | d8997f3caac3f2ab4785e019de07efc550271b74 (diff) |
Add client-side validation in password change forms (#14564)
* Fix client-side username validation at registration It used the Account::USERNAME_RE regexp which is for *remote* users, local user validation is stricter. Also take into account max username length. * Add client-side form validation for password change * Add client-side form validation to dedicated registration form Previous changes only applied to the /about page, not the dedicated form on /auth
Diffstat (limited to 'app/javascript/packs')
-rw-r--r-- | app/javascript/packs/public.js | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/app/javascript/packs/public.js b/app/javascript/packs/public.js index 43b00a77d..5ad25a9b0 100644 --- a/app/javascript/packs/public.js +++ b/app/javascript/packs/public.js @@ -109,6 +109,18 @@ function main() { } }); + delegate(document, '#user_password,#user_password_confirmation', 'input', () => { + const password = document.getElementById('user_password'); + const confirmation = document.getElementById('user_password_confirmation'); + if (!confirmation) return; + + 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')); |