Date picker issue

2019-07-28 04:00发布

问题:

I am going through a strange issue in my Magento module.

  • I cant select dates in magento datepicker (calendar) if the present date is disabled.

  • But, If I click any of the date in present month and go to the next month and comes back, then I can select the dates!!!!!!

My code below,

Calendar.setup({
        inputField : '_dob',
        ifFormat : '%d/%m/%y',
        button : '_dob_trig',
        align : 'Bl',
        singleClick : true,
        date: '25/6/2013',

Here by date attribute, I am trying to set a default date. But it too doesnt work. If I enables the present date to selectable, then the calendar works perfectly!

If anyone went through this before please share your solution.

回答1:

I assume you are using the wrong format for the default date, it needs to be an integer YYYYMMDD.

Have you tried using the min: 20130625 variable in stead of an adjusted default date?



回答2:

I'm not pretty sure work or not. If not work, you may be edit a little bit in this code.

        Calendar.setup({
        inputField : '_dob',
        ifFormat : '%d/%m/%y',
        button : '_dob_trig',
        align : 'Bl',
        singleClick : true,
        disableFunc: function(date) {
              var today = new Date();
              var dd = today.getDate();
              var mm = today.getMonth()+1; //January is 0!

              var yyyy = today.getFullYear();
              if(dd<10){dd='0'+dd} if(mm<10){mm='0'+mm} today = mm+'/'+dd+'/'+yyyy;
              return today;
        }
 });


回答3:

Finally got a solution...!

There is a calendar.js file in magento's default js folder. In that, there is a currentDateEl parameter. I changed it to currentDateEl: 25/06/2013... The issue is solved.