I'm trying to use patterns for my gsp file in Grails. I want to check if the time entered is in the correct format. For example: 12.15 == 12:15 == 12,15 == 12-15 and so on.
<g:field type="text" name="startTime" class="date" pattern="\\$##:##"/>
<g:field type="text" name="endTime" class="date" pattern="[0-9]{2}:[0-9]{2}" />
That's my code. The patterns are just some trys. Maybe someone knows a solution.
Greetings Nik
I found a solution:
<g:textField name="startTime" class="date"
value="${formatDate(format:'HH:mm',date:record.start)}" pattern="\\d{1,2}(:\\d{0,2})?" />
<g:textField name="endTime" class="date"
value="${formatDate(format:'HH:mm',date:record.end)}" pattern="\\d{1,2}(:\\d{0,2})?"/>
I just skiped the part with different dots. Now it shows a warning if you use the wrong pattern.