Where can I find HTML to add role="alert" to error messages in magento. For example, when a user provides a wrong zip code on checkout page this error message shows up.

<div for="postcode" generated="true" class="mage-error" id="postcode-error">Please enter a valid zip code (Ex: 90602 or 90602-1234).</div>

I would like to add an attribute to the above div tag. Magento version is 2.x.

1 Answer 1


I changed a core file to add an attribute to error messages /lib/web/jquery/jquery.validate.js

- .attr({"for": this.idOrName(element), generated: true})
+ .attr({"for": this.idOrName(element), generated: true, role: "alert"})

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.