Greetings.
Working with html date input control.
input type="date" max="2014-13-11"
In chrome its recognizing 'max'attribute hence restricting and disabling all future date
But, the same is not working in iPad/iphone. Instead its allowing to select future date in iPad.
Googled and came to know that ipad is not yet supporting Max attribute of date control.
Is there any work around? or any points / direction will be really help for me.
Many thanks. Karthik
Sadly, support for date input seems to be completely absent in Safari on a Mac. The date input fields are presented as if they were text boxes, and the default value in the first field is not re-interpreted into a human readable format as with other browsers.
jQuery code getFullYear(); if(month < 10) month = '0' + month. toString(); if(day < 10) day = '0' + day. toString(); var maxDate = year + '-' + month + '-' + day; $('#txtDate'). attr('max', maxDate); });
To set and get the input type date in dd-mm-yyyy format we will use <input> type attribute. The <input> type attribute is used to define a date picker or control field. In this attribute, you can set the range from which day-month-year to which day-month-year date can be selected from.
Safari on iOS does not support the attributes max
and min
for input="date"
.
You could use a JavaScript datapicker like Pikaday for this. See demo below:
var today = new Date();
var lastMonth = new Date().getMonth() - 1;
var picker = new Pikaday({
field: document.getElementById('datepicker'),
maxDate: today, // maximum/latest date set to today
// demo only
position: 'top left',
reposition: false
});
<!-- Pikaday Library -->
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/pikaday/css/pikaday.css">
<script src="https://cdn.jsdelivr.net/npm/pikaday/pikaday.js"></script>
<!-- Datepicker Input -->
<label for="datepicker">Date</label>
<input type="text" id="datepicker">
For more info, please refer to the documentation on GitHub.
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