Vincy Joseph
Vincy Joseph

Reputation: 233

jQuery Datepicker minDate is not working in bootstrap

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
});

Upvotes: 12

Views: 27982

Answers (6)

hardik kanzariya
hardik kanzariya

Reputation: 51

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

$('#checkinDate').datepicker({
        format: "dd/mm/yyyy",
        autoclose: true,
        startDate: new Date()
    });

Upvotes: 2

harshil gajra
harshil gajra

Reputation: 11

you can use php date function like this:

this is workingg..↓

      $(document).ready(function(){
          $('#Sdate').datetimepicker({
            minDate:'<?php echo  date('Y-m-d H:i:s');?>'

          });
       });

or you can use this

       $(document).ready(function(){
          $('#Sdate').datetimepicker({
            minDate: new Date()

          });
       });

Upvotes: -1

Syed Shibli
Syed Shibli

Reputation: 1072

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',
   });

Upvotes: 5

ReNiSh AR
ReNiSh AR

Reputation: 2852

For jquery datepicker use:

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

For Bootstrap versions use:

$(".datepicker").datepicker({
     startDate: new Date()
});

Upvotes: 43

Monzurul Shimul
Monzurul Shimul

Reputation: 8386

According to jQuery datepicker api doc http://api.jqueryui.com/datepicker/#option-minDate, if you want to set today as minDate then minDate should be 0.

here is the working fiddle: http://jsfiddle.net/0dn4mtxn/1/

Try this:

$('.datepicker').datepicker({
    autoclose: true,
    todayHighlight: true,
    format: "dd-mm-yyyy",
    minDate: 0,
    clearBtn: true,
    multidate: false,
    multidateSeparator: ",",
    toggleActive: true
});

Upvotes: 0

anjaneyulubatta505
anjaneyulubatta505

Reputation: 11665

Try to change minDate to 0

$('.datepicker').datepicker({
    autoclose: true,
    todayHighlight: true,
    format: "dd-mm-yyyy",
    minDate: 0,
    clearBtn: true,
    multidate: false,
    multidateSeparator: ",",
    toggleActive: true });

Upvotes: 0

Related Questions