简体   繁体   中英

How to disable date before today in datetimepicker bootstrap?

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?

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/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM