1. Fabrik 3.7 is now available. This version contains critical security updates, please update as soon as possible. Please remember to backup your site before updating, we also recommend testing your updates on development sites if possible.
  2. We had to restore the site around midday (CST) on Wed 7/26 from a backup approximately 8 hours old. So a few posts in the forums were lost. You may want to check to see if you need to re-post anything.
  3. The release of Fabrik for J! 3.8 is not yet ready. Do not update your sites to J! 3.8 until this notice is removed.

Comparing two dates in javascript

May 27, 2013
Comparing two dates in javascript
  • Edit your end date element.
    Add a new blur event with the following code:

    Code (Javascript):

    var startid= 'jos_events___start_date_cal';
     
    var endid = 'jos_events___end_date_cal';
     
    var start = document.id(startid).get('value').split('-');
     
    var end = document.id(endid).get('value').split('-');
     
    if (start.length > 1) {
      var startdate = new Date();
      startdate.setFullYear(start[0]);
      startdate.setMonth(start[1].toInt() - 1);
      startdate.setDate(start[2]);
      var enddate = new Date();
      enddate.setFullYear(end[0]);
      enddate.setMonth(end[1].toInt() - 1);
      enddate.setDate(end[2]);
      if (enddate < startdate) {
        alert('woops your end date is earlier than your start date');
        document.id(endid).value = [I];[/I]
      }
     
    }
     
    Edit it so that the first two lines point to the id's of your start and end date fields. This also presumes that your date elements are recording the dates in the format 'yyyy-mm-dd';