Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable future dates in daterangepicker

I am using this plugin for selecting date range, The configuration is my js is as follows:

// date range picker
$('.date_input').daterangepicker({
    autoUpdateInput: false,
    locale: {
        cancelLabel: 'Clear',
        format: 'DD-MM-YY'
    }
});

I need to disable the future dates, i tried using maxDate, but it did not work. Please help me to resolve this issue.Help would be much appreciated Thanks!!

like image 624
Prabhjot Kaur Avatar asked May 10 '16 12:05

Prabhjot Kaur


People also ask

How do I turn off future date in calendar?

In the calendar widget their is an option to select max date, in which you can set the value as CurrDate(). So that future dates in the calendar would be disabled.

How do you turn off future date in date range picker?

daterangepicker({ autoUpdateInput: false, locale: { cancelLabel: 'Clear', format: 'DD-MM-YY' } });

How to disable future date in JavaScript?

If you want to future date disable from today use today. getFullYear() - 10 in order to disable 10 years before which means disable from 2008.


1 Answers

You can use maxDate options

(Date object, moment object or string) The latest date a user may select

$('.date_input').daterangepicker({
    maxDate: new Date()
})
like image 67
Satpal Avatar answered Sep 18 '22 08:09

Satpal