diff --git a/benefits/core/templates/core/includes/form.html b/benefits/core/templates/core/includes/form.html index 4f0932fda..cdf69abac 100644 --- a/benefits/core/templates/core/includes/form.html +++ b/benefits/core/templates/core/includes/form.html @@ -60,7 +60,7 @@ $(this).trigger("submitting"); }); - {% if use_custom_validity %} + {% if form.use_custom_validity %} const validate = function(input_element) { input_element.setCustomValidity(""); // clearing message sets input_element.validity.customError back to false diff --git a/benefits/eligibility/forms.py b/benefits/eligibility/forms.py index d83fc8065..d66ee506b 100644 --- a/benefits/eligibility/forms.py +++ b/benefits/eligibility/forms.py @@ -34,6 +34,7 @@ def __init__(self, agency: models.TransitAgency, *args, **kwargs): verifier_field.choices = [(v.id, None) for v in verifiers] verifier_field.widget.selection_label_templates = {v.id: v.selection_label_template for v in verifiers} verifier_field.widget.attrs.update({"data-custom-validity": _("Please choose a transit benefit.")}) + self.use_custom_validity = True def clean(self): if not recaptcha.verify(self.data): @@ -118,6 +119,7 @@ def __init__( sub_widget.attrs.update({"maxlength": sub_max_length}) if sub_custom_validity: sub_widget.attrs.update({"data-custom-validity": sub_custom_validity}) + self.use_custom_validity = True self.fields["sub"] = forms.CharField( label=sub_label, @@ -130,6 +132,7 @@ def __init__( name_widget.attrs.update({"maxlength": name_max_length}) if name_custom_validity: name_widget.attrs.update({"data-custom-validity": name_custom_validity}) + self.use_custom_validity = True self.fields["name"] = forms.CharField(label=name_label, widget=name_widget, help_text=name_help_text) diff --git a/benefits/eligibility/templates/eligibility/confirm.html b/benefits/eligibility/templates/eligibility/confirm.html index 70897e7d9..31f617422 100644 --- a/benefits/eligibility/templates/eligibility/confirm.html +++ b/benefits/eligibility/templates/eligibility/confirm.html @@ -27,6 +27,6 @@