Page 1 of 1

Date less than today

Posted: 21 Apr 2021
by KateřinaCísařová

can you help me with code, please?

I need to change status if user chooses date less than today.

Thank you very much.


Re: Date less than today

Posted: 04 May 2021
by Nikita Kurguzov
Replied in the other topic, but just in case, the following JS code should work:

Code: Select all

function compareDateToToday(date){
  var q = new Date();
  var m = q.getMonth();
  var d = q.getDate();
  var y = q.getFullYear();

  var today = new Date(y,m,d);
    alert("Date is before today");
  else if (today<date){
    alert("Date is after today")
    alert("Date is today");

  var date = new Date(fd.field('Date').value());
Of course, it might need some adjustments to your case, so if you have any issues - please, post a screenshot of a form with console errors that you get!