I am trying to disable future dates in my Magento custom modal. here is my script. I work perfectly fine in my html file. But when I apply it in Magento, it does not work.

Can someone suggest a better solution? Thanks.

$(function() {
    $(document).ready(function () {
        var todaysDate = new Date();
        var year = todaysDate.getFullYear();
        var month = ("0" + (todaysDate.getMonth() + 1)).slice(-2);
        var day = ("0" + todaysDate.getDate()).slice(-2);
        var maxDate = (year +"-"+ month +"-"+ day);
  • try changing 'max' to 'maxDate' and check.. – aravind Nov 18 '19 at 4:39

Resolved this by changing the type="date" to type="text" and with this code

    ], function ($) {
            showsTime: false,
            hideIfNoPrevNext: true,
            maxDate: new Date(),
            dateFormat: 'dd/mm/yyyy'

Works well.

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.