By using Thymeleaf as template engine, is it possible to add/remove dynamically a CSS class to/from a simple div
with the th:if
clause?
Nor
If you just want to append a class in case of an error you can use th:errorclass="my-error-class"
mentionned in the doc.
Applied to a form field tag (input, select, textarea…), it will read the name of the field to be examined from any existing name or th:field attributes in the same tag, and then append the specified CSS class to the tag if such field has any associated errors