Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery Datepicker minDate is not working in bootstrap

Tags:

jquery

I'm trying to set a minDate for a jquery datepicker. but itz is not working.

$('.datepicker').datepicker({
    autoclose: true,
    todayHighlight: true,
    format: "dd-mm-yyyy",
    minDate: new Date(),
    clearBtn: true,
    multidate: false,
    multidateSeparator: ",",
    toggleActive: true
});
like image 882
Vincy Joseph Avatar asked Feb 21 '17 04:02

Vincy Joseph


3 Answers

For jquery datepicker use:

$(".datepicker").datepicker({
    minDate: 0
});

For Bootstrap versions use:

$(".datepicker").datepicker({
     startDate: new Date()
});
like image 198
ReNiSh AR Avatar answered Nov 10 '22 17:11

ReNiSh AR


In newer bootstrap datepicker version use below method

limiting end date **eg** +1d, +3m, +5y , -1d , -3m, -5y
limiting start date **eg**  +1d, -23d, +3m ,2y, -2y 
$('#dob').datepicker({
            fautoclose: true,
            startDate: '+1y',
   });

 $('#dob').datepicker({
            fautoclose: true,
            endDate: '-18y',
   });
like image 20
Syed Shibli Avatar answered Nov 10 '22 18:11

Syed Shibli


to disable past dates use startDate instead of minDate. like this...

$('#checkinDate').datepicker({
        format: "dd/mm/yyyy",
        autoclose: true,
        startDate: new Date()
    });
like image 2
hardik kanzariya Avatar answered Nov 10 '22 17:11

hardik kanzariya