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.
Relevant code:
<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)
Other relevant information:
As far as I can tell the HTML 5 specification allows min and max in both cases.
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.
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.
Am I missing something obvious?
The min attribute specifies the minimum value (time) for a time field. Tip: Use the min attribute together with the max attribute to create a range of legal values. Tip: To set or return the value of the max attribute, use the max property.
If you want the time with AM & PM, check the first two values, and utilize something like the following: if(FirstTwoNums > 12){ FirstTwoNums -= 12; PM = true;}/*else, PM is false */ .
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With