5 Replies Latest reply: Oct 30, 2014 8:13 PM by Paul Dokken RSS

    Determine if end date is after start date

    Paul Dokken Community Member

      I have 2 date fields on a form.  When I click the submit button I am trying to make sure the end date is after the start date.

       

      Here is the code I am using:

           var sDate = Date.parse(BackgroundInformation.Background.CheckingDateStart.rawValue);

            var eDate = Date.parse(BackgroundInformation.Background.CheckingDateEnd.rawValue);

            xfa.host.messageBox("Start Date:" + BackgroundInformation.Background.CheckingDateStart.rawValue);

            xfa.host.messageBox("eDate:"+eDate+" sDate:"+sDate);

            if(sDate > eDate)

      {
         valid = false;
         fieldName +="Start Date is greater than End Date";
      }

       

      The message box shows the start date as 2014-10-30 but sDate is Nan.

       

      I have tried:

           var eDate = new Date(BackgroundInformation.Background.CheckingDateEnd.rawValue);

            var sDate = new Date(BackgroundInformation.Background.CheckingDateStart.rawValue);

       

      and when I display sDate is says "Invalid Date"

       

      Any ideas?