Bootstrap date picker endDate

16,234

Thanks for attention. Problem solved, I have added datesDisabled same as endDate!

endDate: '+1d',
datesDisabled: '+1d',
Share:
16,234
Sabutobi
Author by

Sabutobi

Updated on July 15, 2022

Comments

  • Sabutobi
    Sabutobi almost 2 years

    I have this bootstrap datepicker config:

    datePickerConfig: {
        changeMonth: true,
        numberOfMonths: 1,
        endDate: new Date(),
        startDate: moment().subtract(1, 'year').toDate(),
        showOn: 'both',
        buttonImageOnly: true,
        buttonText: 'Select date',
        firstDay: moment.localeData().firstDayOfWeek(),
        dateFormat: 'L',
        autoclose: true
    }
    
    $('#someId').datepicker(datePickerConfig).datepicker('setDate', new Date())
    

    Problem: In this case my input field will be empty: enter image description here

    If I do this:

    $('someId').datepicker('setEndDate', '+1d');
    

    I won't have empty input like above but in my datepicker will be possible select tomorrow date. See screen below: enter image description here

    What value should I set to endDate, if want that I my datepicker last date, that had to be selected, is date of today. And when I init datepicker also I need date of today.