HTML 5的24小时时间正则表达式 [英] 24 hour time regex for HTML 5

查看:94
本文介绍了HTML 5的24小时时间正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

想查询关于HTML 5(HH:MM)中24小时时间格式的可能正则表达式。 如果可能的话,请告诉可以在HTML 5的Pattern属性中使用的正则表达式



时间预计为24小时制(HH不超过23)。



亲切的问候,

解决方案

我认为这是一种可能的方法:

 < ; input type =textpattern =([01]?[0-9] | 2 [0-3]):[0-5] [0-9]id =24h/> 
< input type =textpattern =([01]?[0-9] {1} | 2 [0-3] {1}):[0-5] {1} [0 -9] {1}id =24h/>

http://www.mkyong.com/regular-expressions/how-to-validate-time-in-24-hours- format-with-regular-expression /

 ([01]?[0-9] | 2 [0 -3]):[0-5] [0-9] 

看看这个jsfiddle:< a href =http://jsfiddle.net/Y6gjt/>示例


Wanted to Inquire about the possible Regex expression for 24-hour time format in HTML 5 (HH:MM) .

if possible, kindly tell the regex that can be used in the Pattern attribute of HTML 5

The time is expected to be in 24-hour format (HH not more than 23).

Kind regards,

解决方案

I think this is a possible approach :

<input type="text" pattern="([01]?[0-9]|2[0-3]):[0-5][0-9]" id="24h"/>
<input type="text" pattern="([01]?[0-9]{1}|2[0-3]{1}):[0-5]{1}[0-9]{1}" id="24h"/>

http://www.mkyong.com/regular-expressions/how-to-validate-time-in-24-hours-format-with-regular-expression/

([01]?[0-9]|2[0-3]):[0-5][0-9]

Check out this jsfiddle : example

这篇关于HTML 5的24小时时间正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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