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

    Validation of two calendar components in javascript

      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

      ondatechangedr="validateDates();"

       

      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();

      alert(startTime);

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

      alert(endTime);

      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.");

              }

             }

      /* ]]> */

      </script>

       

      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!