samuel toh samuel toh - 1 year ago 116
Javascript Question

How to disable date before today in datetimepicker bootstrap?

Demo and full code is like this :

My Javascript code is like this :

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?

Answer Source

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?

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download