jquery datepicker range (mindate maxdate) is not working

左心房为你撑大大i 提交于 2019-12-01 21:27:43

As far as I know, it should be done like this:

$("#datepicker").datepicker('option', {minDate: <some date>, maxDate: <some date>});

What you are missing is that you should set them using 'option'.

VishalDream
$('#datepicker').datepicker({
            maxDate: '0'}),

Use '0' for select max date today

You can also reference jQueryUI Api

$('#datepicker').datepicker({
                maxDate: '+1m',
                minDate: '-20d',
                });

When min and max date are expressions they should be as strings and properly defined. Here is link for jquery ui datepicker MaxDate section.

One more thing, you might have noticed that already, but your selector is searching for ID as "datepicker". Whereas, your datepicker is your CLASS. So I think you need to change from "#datepicker" to ".datepicker".

just add in controller if you are using angularjs $scope.today = new Date()

and in html min-date="today"

AlejandroBec

You can also test this.

$('#datepicker1').datepicker({
  format: 'mm/dd/yyyy',
});

$('#datepicker1').on('change', function() {
  $('#datepicker2').datepicker({
    startDate: $('#datepicker1').val()
  })
});
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!