html 5用最小值和最大值形成输入类型时间 [英] html 5 forms input type time with min and max
问题描述
我能够在我正在设计的形式中使用输入类型日期和最小和最大属性尽可能地利用HTML 5.但是如果输入类型是时间,我无法做同样的事情。
I have been able to use input type date with min and max attributes in a form I am designing taking advantage as much as possible of HTML 5. Nevertheless I am not able to do the same if input type is time.
相关代码:
<input style='width:120px' required name='dia' id='dia' type='date' min="1991-01-01" max="2014-05-12">
<input style='width:80px' required name='hora' id='hora' type="time" min="08:00:00" max="20:00:00"/>
(后者的最小值和最大值被忽略)
(min and max in the latter are ignored)
其他相关信息:
-
据我所知,HTML 5规范允许两种情况下的最小值和最大值。
As far as I can tell the HTML 5 specification allows min and max in both cases.
我正在为此表单使用minimizr和webshims,这使得FF等输入日期字段可用。
I am using minimizr and webshims for this form which makes input date fields available in FF, etc.
最近的主要浏览器之间没有检测到不同的行为。
No different behavior detected between recent major browsers.
像W3C学校这样的网站提到日期的最小值和最大值,但没有提及可能表示普遍缺乏对最小值和最大值的热情作为时间属性。
A site like W3C schools mentions min and max for date but not for time which may indicate a general lack of enthusiasm for min and max as attributes for time.
我错过了一些明显的东西吗? / p>
Am I missing something obvious?
推荐答案
它有效。它会被触发,因为它说的是大于或等于08:00的时间。 (在chrome中测试)
其他一些浏览器忽略属性min,max,required,所以要注意用JS做。
It works. It get triggered on oubmit saying type a time bigger or equal to 08:00. (Tested in chrome)
Some other browser ignore attribute min, max, required so pay attention to do it with JS too.
这篇关于html 5用最小值和最大值形成输入类型时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!