0

I'm using this code, but could not select any date in datepicker. Why? When I change months then I can select dates. I used disableFunc to disable next 3 days and sundays in calendar. When I remove that disableFunc I can select dates. Any solution?

Calendar.setup({
        inputField : '_dob',
        ifFormat : '%m/%e/%y',
        button : '_dob_trig',
        align : 'Bl',
        singleClick : true,
        disableFunc: function(date)
        {
            var first_day = new Date();
            var second_day= new Date();
            var third_day= new Date();

            first_day.setDate(first_day.getDate());
            if(first_day.getDay()===0)
            {
                 first_day.setDate(first_day.getDate()+1);
            }

            second_day.setDate(first_day.getDate()+1);
            if(second_day.getDay()===0)
            {
                second_day.setDate(first_day.getDate()+2);
            }

            third_day.setDate(second_day.getDate()+1);
            if(third_day.getDay()===0)
            {
                third_day.setDate(second_day.getDate()+2);
            }


            var flag1 = first_day.getDate()===date.getDate() && first_day.getMonth()===date.getMonth() && first_day.getYear()===date.getYear();
            var flag2 = second_day.getDate()===date.getDate() && second_day.getMonth()===date.getMonth() && second_day.getYear()===date.getYear();
            var flag3 = third_day.getDate()===date.getDate() && third_day.getMonth()===date.getMonth() && third_day.getYear()===date.getYear();

            if(date.getDay() === 0 || flag1 || flag2 || flag3)
            {  return true; }

        }
    });
ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199
HungryDB
  • 555
  • 3
  • 11
  • 30

2 Answers2

0

I think this answer might be helpful to you. It is suggested to avoid using == or ===

Compare two dates with JavaScript

Community
  • 1
  • 1
shiva kumar
  • 121
  • 5
  • Note in [SO] link only answers are not welcome. Try to give some explanation. And in case the question is quite similar, then the question can be closed as duplicated. – fedorqui Oct 20 '14 at 12:21
0

Got solution -

If you disable the current date then only this problem arises. i tried to remove current date from disabled dates and it works fine.

If you still want to disable current date then visit this link and follow the instructions.

Disable current date in dynarch popup calendar

HungryDB
  • 555
  • 3
  • 11
  • 30