Task end date is automatically equal to start date if it is less than start date. How to disable this


Task end date is automatically equal to start date if end date is less than start date when I use lightbox.
How to disable this? I don’t want to make automatically this. Because I need to show alert message to users they they have selected wrongly.


Hello Suba,
You need to use the onLightboxSave event to validate the lightbox values:

You supposed to use the following commands to get the start_date and end_date values:


But unfortunately, there is a bug, so you will get the wrong end_date value, and it is still greater than the start_date:

The dev team will fix it in the future, but I cannot give you any ETA.

As a workaround, you need to obtain the values manually from the DOM elements:

gantt.attachEvent("onLightboxSave", function(id, task, is_new){
  var node = gantt.getLightboxSection('time').node;
  var date = {day:null, month:null, year:null};
  date.day = document.querySelectorAll("select[aria-label='Days']")[1].value;
  date.month = document.querySelectorAll("select[aria-label='Months']")[1].value;
  date.year = document.querySelectorAll("select[aria-label='Years']")[1].value;
  var actual_end_date = new Date(date.year, date.month, date.day)
  if (+gantt.getLightboxValues().start_date > +actual_end_date){
    gantt.message({type: "error", text: "Correct the start_date"})
    return false;
  return true;

The following snippet demonstrates how it works: