I am using the date input type in HTML5. It is displaying the correctly in the format dd-MM-yyyy. However the min and max values does not validate correctly, because it validates against the format yyyy-MM-dd. I have not been able to change the format the min and max values validates, any ideas?
<input type="date" name="DateName" id="DateID" min="2000-01-01" max="2100-12-31"/>
The attributes value
, min
and max
have the same format for dates. They follow the RFC 3339 where the full data syntax is as:
full-date = date-fullyear "-" date-month "-" date-mday
date-fullyear = 4DIGIT
date-month = 2DIGIT (01-12)
date-mday = 2DIGIT (01-28, 01-29, 01-30, 01-31)
So even if the browser displays you the date in format dd-mm-yyyy
internally it's using this syntax.
Anyway, this HTML5 input type is only supported in Safari, Chrome and Opera.
You can try this Fiddle with invalid dates as 12/12/2014, when you submit the form an error message is displayed.
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