Min/max Attribute With Type = Date On Html5
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>
Solution 3:
The HTML5 datepicker component now works in most browsers and the minimum and maximum control attributes are fully implemented. The correct format is yyyy-mm-dd, as described in the mozilla documentation.
<inputtype="date"id="birthday" name="birthday"min="2020-01-20"max="2021-01-28">
A simple example adapted from w3school:
<!DOCTYPE html><html><body><h1>Show a Date Control</h1><labelfor="birthday">Birthday:</label><inputtype="date"id="birthday"name="birthday"min="2020-01-20"max="2021-01-28"><p><strong>Note:</strong> type="date" is not supported in Safari or Internet Explorer 11 (or earlier).</p></body></html>
As supplementary information, from the HTML5 specification documentation.
In session 4.10.5.1.7 Date state (type=date), we read:
The min attribute, if specified, must have a value that is a valid date string. The max attribute, if specified, must have a value that is a valid date string.
And in the other session, 4.10.1.8 Date, time, and number formats, we find:
...is intended to be computer-readable and consistent irrespective of the user's locale. Dates, for instance, are always written in the format "YYYY-MM-DD", as in "2003-02-01".
Post a Comment for "Min/max Attribute With Type = Date On Html5"