feat(users): adds in client password matching validation

This commit is contained in:
2024-11-17 22:39:04 -03:00
parent d00fd4220d
commit f3f4912e41
2 changed files with 9 additions and 1 deletions

View File

@@ -87,7 +87,7 @@
required
type="password"
>
{{ form_field_validation(FORM_ERRORS['REQUIRED'] + " " + FORM_ERRORS['PASSWORD_LENGTH']) }}
{{ form_field_validation(FORM_ERRORS['REQUIRED'] + " " + FORM_ERRORS['PASSWORD_LENGTH'] + " " + FORM_ERRORS['MUST_MATCH_PASSWORD']) }}
</div>
<div class="col-12">
<label class="form-label" for="address">Address</label>
@@ -118,6 +118,13 @@
form.classList.add('was-validated')
}, false)
})
const password = document.getElementById("password")
const password_validation = document.getElementById("password-confirmation")
password.addEventListener('change', (c) => {
password_validation.setAttribute("pattern", c.target.value)
})
})()
</script>
{% endblock %}

View File

@@ -1,6 +1,7 @@
FORM_ERRORS = {
'REQUIRED': "This field is required.",
'PASSWORD_LENGTH': 'It must be at least 6 characters long.',
'MUST_MATCH_PASSWORD': 'It must match the given password.',
'VALID_EMAIL': 'Enter a valid email address.',
'PHONE_NUMBER_FORMAT': 'It can be prefixed with the "+" sign and may only contain numbers after it.',
'NAME_FORMAT': 'It must be at least 2 characters long, it may only contain letters.'