admin管理员组

文章数量:1394593

I have the following code which disables the current date by setting minDate to current date + 1:

    var today = new Date();
    var tomorrow = new Date();
    tomorrow.setDate(today.getDate() + 1);

        $("#minDate").datepicker({
            showOn: "none",
            minDate: tomorrow,
            dateFormat: "DD dd-mm-yy",
            onSelect: function(dateText) {
                minDateChange;
            },
            inputOffsetX: 5,
        });

The problem is that I want to disable the current date, but still keep it highlighted (Blue border around the date) in the calendar.

Is there a native way to do this using the datepicker or do I have to create a highlight script myself?

I have the following code which disables the current date by setting minDate to current date + 1:

    var today = new Date();
    var tomorrow = new Date();
    tomorrow.setDate(today.getDate() + 1);

        $("#minDate").datepicker({
            showOn: "none",
            minDate: tomorrow,
            dateFormat: "DD dd-mm-yy",
            onSelect: function(dateText) {
                minDateChange;
            },
            inputOffsetX: 5,
        });

The problem is that I want to disable the current date, but still keep it highlighted (Blue border around the date) in the calendar.

Is there a native way to do this using the datepicker or do I have to create a highlight script myself?

Share Improve this question edited Mar 6, 2014 at 8:24 Dumpen asked Apr 17, 2013 at 11:48 DumpenDumpen 1,6726 gold badges22 silver badges36 bronze badges 2
  • Isn't the highlighted date the default chosen? If so, it can't be chosen and out of defined range at the same time. – Jakub Matczak Commented Apr 17, 2013 at 11:59
  • 1 First, just disable current date by, minDate: "+1D", and then override its style as: .ui-datepicker-today span{background: #036!important; something else....} to anything you need. – HENG Vongkol Commented Aug 28, 2016 at 12:33
Add a ment  | 

2 Answers 2

Reset to default 1

you don't need to set today and tomorrow as a variable. just set minDate: 1

The datepicker has a class on todays date called "ui-datepicker-today", so I simply added a class to that:

$(".ui-datepicker-today span").addClass("ui-state-hover")

本文标签: javascriptjQuery UI DatepickerDisable current date but NOT the highlightStack Overflow