I am using DateRangePicker for dates. I was trying to disable past dates by setting min date to current date as below.It does not do any thing.
$('.daterange-single').daterangepicker({
singleDatePicker: true,
minDate: today
});
but it is working fine when you give actual date as below.
$('.daterange-single').daterangepicker({
singleDatePicker: true,
minDate: "7/11/2019"
});
Please help me how to set minDate to current date in DateRangePicker
You can set minDate
at current date in daterangepicker. You can try the below code:
$(function() {
$('input[name="birthday"]').daterangepicker({
singleDatePicker: true,
showDropdowns: true,
minYear: 1901,
minDate: new Date(),
maxYear: parseInt(moment().format('YYYY'),10)
});
});
<script type="text/javascript" src="https://cdn.jsdelivr.net/jquery/latest/jquery.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/momentjs/latest/moment.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.css" />
<input type="text" name="birthday" />