How to disable date before today in datetimepicker bootstrap?

狂风中的少年 提交于 2019-12-13 22:05:00

问题


Demo and full code is like this : http://fiddle.jshell.net/oscar11/dgb09c5c/5/

My Javascript code is like this :

$('#time-start').datetimepicker({
    format: 'yyyy-mm-dd hh:ii:ss',
    autoclose: true,
    pickerPosition: "bottom-left",
    maxView: 3,
    minuteStep: 1,
    minDate: new Date()
})

How to disable date before today?

I add minDate: new Date(), but it's not working

Any solution to solve my problem?


回答1:


From Bootstrap datetime picker documentation

$.fn.datetimepicker.defaults = {
  maskInput: true,           // disables the text input mask
  pickDate: true,            // disables the date picker
  pickTime: true,            // disables de time picker
  pick12HourFormat: false,   // enables the 12-hour format time picker
  pickSeconds: true,         // disables seconds in the time picker
  startDate: -Infinity,      // set a minimum date
  endDate: Infinity          // set a maximum date
};

I modified your Fiddle. Is it what you are looking for? http://fiddle.jshell.net/dgb09c5c/6/



来源:https://stackoverflow.com/questions/38515419/how-to-disable-date-before-today-in-datetimepicker-bootstrap

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!