1 Reply Latest reply on Mar 10, 2008 6:27 AM by gkaiseril

    Problem with Date/Time field in Adobe LiveCycle

      I am trying to create a form that has a check-in and check-out dates. I want the user to enter those dates and then have the form automatically compute how many nights the user intends on staying.

      I have two fields, CHECKIN and CHECKOUT, set up as text fields. My third field, NIGHTS, has the following script to do the calculation:

      var strStart = CHECKIN.rawValue
      var strEnd = CHECKOUT.rawValue

      if(strStart.length && strEnd.length)
      {
      var dateStart = util.scand("mmm d, yyyy",strStart);
      var dateEnd = util.scand("mmm d, yyyy",strEnd);
      var diff = dateEnd.getTime() - dateStart.getTime();
      var oneDay = 24 * 60 * 60 * 1000;
      var days = Math.floor(diff/oneDay);
      this.rawValue = days;
      }
      else
      this.rawValue = 0;

      NOW...this is fine if the user inputs a four-digit year. If not, it's trouble. SO, what I want to do is change the CHECKIN and CHECKOUT fields to the date/time field so they select the date off the pop-up calendar.

      When I make the changes, I can't get the script to work for the NIGHTS field.

      CAN ANYONE HELP THIS NEWBIE?