Softwaretech
Softwaretech

Reputation: 319

jQuery DatePicker does not compare years

It was brought to my attention, using jQuery DatePicker, when comparing dates, the only part of the dates being compared is month and day.

$("#complete_date").datepicker({
    minDate: 0,
    beforeShowDay: noWeekendsOrHolidays,
    onSelect: function(date) {
        if (date < choice_date)
        {
            $("#early_dialog").dialog("open");
            if ($("#alert").length < 1)
            {
                $(".ui-dialog-title").append("<img src='/icon_alert.gif' id='alert'>");
            }
        }

    }
});

Basically, the test is if today's date is 8/1/2013 and I choose 1/14/2014, the early_dialog message still appears.

Suggestions?

Upvotes: 0

Views: 90

Answers (1)

GeniusJRS
GeniusJRS

Reputation: 119

Use $("#datepicker_xxx").datepicker("getDate") to get the picked date as a Date. Then it's just a matter of

end - begin > 7 * 86400 * 1000

Upvotes: 1

Related Questions