It is possible to limit the "range" between two dates in the <input type="month">
?
You can use the attributes min
and max
.
Thus:
<input id="aniversario" type="month" name="aniversario"
min="1900-01" max="1999-12">
If yes, there is some mandatory format standard that we should follow when passing values that limit?
In the case of [type=month]
, The format needs to be YYYY-MM
(where YYYY
is 4 digit year and MM
is the month with two digits).
This "limit" is supported by which browsers and mobile devices?
According to the compatibility table of MDN, support is not yet complete.
In my Firefox, for example, it didn’t work. And there is a bug has been informed of such input.
Also, Internet Explorer and Safari are not supported yet.
On Android, it seems that Firefox also has no support.
Validation
In addition, the MDN warns about data entry validation:
By default, input[type="month"]
does not apply any validation to the entered values. User interface implementations usually do not allow you to enter anything other than a date, which is useful, but you can still submit the form with the empty entry or enter an invalid date (for example, on April 32).
Polyfill
I found a Polyfill to the input[type=month]
, but it seems to me that the same depends on jQuery (thing that I do not like very much).