cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot add min and max date range

Cannot add min and max date range

I face a problem on my date range picker on magento CMS page where i want to set only available to select from 28/10/2025 till 31/10/2025 image (1).png image (2).png
Please need the guidance, i have try using dateRangePicker also now working

1 REPLY 1

Re: Cannot add min and max date range

Hello @kelvinaoec77cd,

 

Here is the full code including both the HTML and JavaScript to implement the Magento date range picker with a minimum and maximum date restriction (October 28, 2025 - October 31, 2025)

 

Add This HTML to Your CMS Page or Template

 

<div class="form-group">

    <label class="boldfont" for="EventDate">Event Date*</label>

    <div class="field dateranges" id="daterange">

        <input class="input-text" type="text" id="from-date" name="from-date" required />

        <span style="padding: 10px;"> - </span>

        <input class="input-text" type="text" id="to-date" name="to-date" required />

    </div>

</div>

Add This JavaScript to Initialize the Date Picker

 

require(['jquery', 'mage/calendar'], function ($) {

    $(document).ready(function () {

        // Initialize "From Date" Picker

        $('#from-date').calendar({

            buttonText: 'Choose Date',

            minDate: '10/28/2025',

            maxDate: '10/31/2025' 

        });



        // Initialize "To Date" Picker

        $('#to-date').calendar({

            buttonText: 'Choose Date',

            minDate: '10/28/2025',

            maxDate: '10/31/2025' 

        });

    });

});

The HTML:  creates a form with two input fields (from-date and to-date).

 

The JavaScript:

 

Loads Magento’s mage/calendar module.

Initializes the date picker on both input fields.

Sets the minDate to October 28, 2025.

Sets the maxDate to October 31, 2025.

see image below all other date has been disabled.

 

Translation Extension question.png

 

If the issue is resolved, click Kudos and accept it as a solution