In Magento 2 how to restrict previous dates in datepicker ,in detail page customizable options,
Please help me out on this .
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communityIn your script add the following
$customId = <?php echo $product->getCustomId();?>
<script>
require([
'jquery',
'mage/calendar'
], function($, calendar) {
$('#<?php echo $customId;?>').calendar({
dateFormat: 'dd/M/Y',
changeMonth: true,
changeYear: true,
yearRange: '2000:2050',
minDate: new Date(),
});
});
</script>
If you are using Magento calendar library or jQuery date picker library then use below method
require([
"jquery",
"mage/calendar"
], function ($) {
$('#example').datepicker({
dateFormat: "yy-mm-dd",
timeFormat: "H:m:s",
changeMonth: true,
changeYear: true,
numberOfMonths: 1,
showsTime: true,
minDate: new Date()
});
});
In this, the minDate is the Date before which you want to restrict.