1 Reply Latest reply on May 18, 2010 4:47 PM by Sean W

    Validation of two calendar components in javascript

    Sean W Newbie

      I'm really scratching my head here.  I am using version 3.3.3.Final and I have two calendars.  On each of them I have



      I need to look up each of the data values of these so I can ensure that each is within 5 days of the other.  I'm unable to identify the elements that contain the dates.  The calendar ids are startTime and endTime.  Any guidance would be appreciated.  My javascript function looks a bit like this:


      <script type="text/javascript">

      /* <![CDATA[ */

      function validateDates() {

      var startTime = $('base-layout-form:startTime').component.getCurrentDate().getTime();


      var endTime = $('base-layout-form:endTime').component.getCurrentDate().getTime();


      var startNum = Number(startTime);

      var endNum = Number(endTime);


              var difference = (endNum - startNum) / (86400000 * 7);

              //alert("start:" + startNum + " end:" + endNum + " diff:" + difference);


              if (difference < 0) {

                  alert("The start date must come before the end date.");


              else if (difference > 5) {

                  alert("The date ranges can be only 5 days wide.");



      /* ]]> */



      The problem I'm facing right now is that the value of startTime and endTime always match for some reason even though the dates in the popups are different!