function checkDate(startDate, endDate, num, flag) { if(startDate == null || endDate == null) { popwin.info('prompt','date cannot be empty'); return false; } if(startDate == '' || endDate == '') { popwin.info('prompt','Please enter query date'); return false; } var start_date = startDate + " 00:00"; var end_date = endDate + " 00:00"; start_date = new Date(start_date.replace(/-/g, "/")); end_date = new Date(end_date.replace(/-/g, "/")); if(start_date > end_date){ popwin.info('prompt','deadline cannot be less than the start date'); return false; } // Get the date after num days var currentDate = new Date(); currentDate.setDate(currentDate.getDate() + num); if(end_date > currentDate) { popwin.info('prompt','deadline cannot be greater than ' + num + 'date after days'); return false; } // Check whether to query across months if(flag == false) { if(start_date.getMonth() != end_date.getMonth()) { popwin.info('tip','This query does not support cross-month query'); return false; } } }