2

I have successfully added calender and disable previous Date in my custom form by using below code.

<script>
require([
    "jquery",
    "mage/calendar"
], function ($) {

    $("#My_ID").calendar({
        showsTime: false,
        hideIfNoPrevNext: true,
        buttonText: "<?php echo __('Select Date') ?>",
        minDate: new Date(),
        dateFormat: 'yy-mm-dd'
    });
});

How to disable List of dates which is in my database ?

1 Answer 1

2

Hi you can this code for disable dates

var disableddates = ["20-06-2016", "12-06-2016"]; // assign your database dates
function DisableSpecificDates(date) {
                    var string = jQuery.datepicker.formatDate('dd-mm-yy', date);
                    return [disableddates.indexOf(string) == -1];
                  }

                jQuery("#My_ID").calendar({
                        beforeShowDay: DisableSpecificDates
                    });
1
  • How to display only specific dates in calender? Commented Oct 13, 2023 at 4:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.