1

I have successfully added calender 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') ?>",
                //dateFormat: "yy-mm-dd"
            }); 
                    });             
            </script>

But, How can I disable previous days in default magento2 calendar?

Any help will be appreciated.

Thanks.

  • Can you show me step by step to add this script to from ? – MrTo-Kane Mar 14 '16 at 7:14
9

You can set your minDate or maxDate in order to limit your calendar.

<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'
        });
    });
</script>
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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