search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Testing and message for attempt to create new event before current time and date

Asked by JC
12 years ago.

I want to generate a popup (Javascript alert) that tells someone that they are attempting to set an event prior to the current time and date.

Answer posted by Dan Letecky [DayPilot]
12 years ago.

It depends on how you are creating a new event. If it's directly on TimeRangeSelected it could look like this:

TimeRangeSelectedHandling="JavaScript"
TimeRangeSelectedJavaScript="check(start, end, resource)"
<script style="text/javascript">
function check(start, end, resource) {
  var now = new DayPilot.Date();
  // var today = now.getDatePart();
  
  if (end.getTime() < now.getTime()) {
    if (!(confirm('Are you sure that you want to create an event in the past?')) {
      return;
    }
  }
  dpc.timeRangeSelected(start, end, resource);
}
</script>
Comment posted by JC
12 years ago.

I am double clicking a free area. As such, there is no start or end

Comment posted by Dan Letecky [DayPilot]
12 years ago.

The double click event is handled by TimeRangeDoubleClick but otherwise it's the same. The start and end variables will hold the cell start and end, respectively.

This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.