Remove double errors on form

This commit is contained in:
Rebecca Hsieh 2024-01-30 11:55:44 -08:00
parent 7d2f4f7f4e
commit a05afb0958
No known key found for this signature in database

View file

@ -220,12 +220,14 @@ function validateFormsetInputs(e, availabilityButton) {
// Run validators for each input
inputs.forEach(input => {
runValidators(input);
removeFormErrors(input, true);
});
// Set the validate-for attribute on the button with the collected input IDs
// Not needed for functionality but nice for accessibility
inputs = inputs.map(input => input.id).join(', ');
availabilityButton.setAttribute('validate-for', inputs);
}
// <<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>>
@ -260,17 +262,6 @@ function validateFormsetInputs(e, availabilityButton) {
button.addEventListener('click', validateFieldInput);
}
}
// Clear errors on auto-validated inputs when user reselects input
const autoValidateInputs = document.querySelectorAll('[auto-validate]');
if (autoValidateInputs) {
for (const input of autoValidateInputs){
input.addEventListener('input', function() {
removeFormErrors(input, true);
}
);
}
}
})();
/**