diff options
author | ThibG <thib@sitedethib.com> | 2020-08-11 23:09:13 +0200 |
---|---|---|
committer | Starfall <us@starfall.systems> | 2020-08-25 13:36:48 -0500 |
commit | d8997f3caac3f2ab4785e019de07efc550271b74 (patch) | |
tree | bec6a6198700603fe36043abbff6bdadbfc65291 /app/javascript/packs | |
parent | a8149a4de707f34481041257c9a7285832139929 (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.js | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/app/javascript/packs/public.js b/app/javascript/packs/public.js index 3d190d2da..43b00a77d 100644 --- a/app/javascript/packs/public.js +++ b/app/javascript/packs/public.js @@ -99,6 +99,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')); |