2016-07-28 6 views
-1

Ich versuche, ein Eingabedatum zu validieren Format TT/MM/yyyy wie das haben:thymeleaf Muster dd/MM/yyyy

<input type="date" th:pattern="${date_format}" th:field="*{subscriptionDate}"/> 

In meinem Controller, füge ich ein Attribut zu meinem Modell wie folgt aus:

model.addAttribute("date_format", "dd/MM/yyyy"); 

Aber wenn ich mein Formular habe ich diese Nachricht von meinem Input-Tag:

Bitte beachten Sie das Format

+0

Das Muster-Attribut erwartet einen regulären Ausdruck, übrigens https://html.spec.whatwg.org/multipage/forms.html#the-pattern-attribute –

Antwort

0

ich mein Problem lösen durch mein Modell wie das Attribut Aktualisierung:

model.addAttribute ("date_format", „\ d {1,2}/\ d {1,2}/\ d {4 } ");