min/max attribute with type = date on HTML5
11,129
Solution 1
Some browsers like Safari and Internet Explorer does not support this functionality, this may be your problem. Write validation via Javascript.
The list of browers that support this feature can be seen at:...
http://html5test.com/compare/browser/chrome-33/firefox-27/opera-19/safari-7.0/ie-11.html
Solution 2
min and max attributes for date input type have very little browser support. You can use jQuery validation as a workaround.
<input id="dateInput" required="required" min="1900-01-01" max="2099-09-13" type="date" class="form-control">
<script>
$("#dateInput").validate();
</script>
Author by
Felipe Carminati
Updated on June 29, 2022Comments
-
Felipe Carminati almost 2 years
I'm having some problems to set a minimum and a maximum YEAR with HTML5 date input.
Here is my code:
<input required="required" min="1900-01-01" max="2099-09-13" type="date" class="form-control" id="inputDataNascimento">
It doesn't work at all.
Am I doing something wrong? Is this a bug?
Notes: I'm using Google Chrome and Twitter Bootstrap 3.
-
Felipe Carminati about 10 yearsI'm using Chrome :/ . Date is working. 'min' and 'max' are not. :(
-
alexmac about 10 yearsAre you using Jquery? There are some nice widgets there some nice date functions. query ui
-
Bob Brown about 3 yearsSadly, the minimum and maximum controls still don't work for Safari on iOS.
-
stevec over 2 years"Fully implemented" is in the eye of the beholder. In Chrome, at least, the min and max apply to the date picker associated with the input, but not with changes typed into the input box. (As of Version 93)