I have made a HTML/thymeleaf form where one of the elements is a date picker, and I have made a java function to check if the date picked is smaller or greater than the current date. If it's smaller it should return the error, if it's greater it should submit the form. The function currently returns true/false respectively
I am unsure how to use this java function in the html to show an error if the function returns true? Where would that go in the element?
Use Thymeleaf's conditional expressions along with the th:if attribute
<!-- Your date picker input element -->
<input type="date" th:field="*{selectedDate}" />
<!-- Display an error message if the selected date is smaller than the current date -->
<div th:if="${yourJavaFunction(*{selectedDate})}">
<span style="color: red;">Error: Selected date cannot be in the past.</span>
</div>