不同时间格式的Grails字段模式 [英] Grails field pattern for different time formats

查看:244
本文介绍了不同时间格式的Grails字段模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在Grails中使用我的gsp文件的模式。我想检查输入的时间是否是正确的格式。
例如:12.15 == 12:15 == 12,15 == 12-15等等。

 < g:field type =textname =startTimeclass =datepattern =\\ $ ##:##/> 
< g:field type =textname =endTimeclass =datepattern =[0-9] {2}:[0-9] {2}/>

这是我的代码。模式只是一些trys。
也许有人知道一个解决方案。



问候语
Nik

解决方案

我找到一个解决方案:

 < g:textField name =startTimeclass =date 
value =$ {formatDate(format:'HH:mm',date:record.start)}pattern =\\d {1,2}(:\\d {0, 2})? />
< g:textField name =endTimeclass =date
value =$ {formatDate(format:'HH:mm',date:record.end)}pattern = ?\\\d {1,2}(:\\d {0,2})/>

我刚刚跳过了不同点的部分。现在,如果您使用错误的模式,则会显示警告。


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.

这篇关于不同时间格式的Grails字段模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆