I'm looking to restrict the date picker based on a the current time function of the time variable in Laserfiche 10.2, where if it is before noon, to restrict the date picker to only allow the current date, or future dates. If it is after noon, then restrict it to only allow the next day, or future dates.
I have a working setup using two different date fields, field rules, and two nearly identical sets of JavaScript. One datefield is using the CSS class of calendarDate and the other using calendarDate2.
Here's the JavaScript that is in place:
/* Restricts Date Picker from allowing current and past dates to be chosen */ $(function() { $(document).ready(function (){ var todaysDate = new Date(); // Gets today's date var year = todaysDate.getFullYear(); // YYYY var month = ("0" + (todaysDate.getMonth() + 1)).slice(-2); // MM var day = ("0" + (todaysDate.getDate() )).slice(-2); // DD var minDate = (year +"-"+ month +"-"+ day); // Results in "YYYY-MM-DD" for tommorrow's date // Now to set the max date value for the calendar to be today's date $('.calendarDate input').attr('min',minDate); }); }); /* Restricts Date Picker from allowing current and past dates to be chosen */ $(function() { $(document).ready(function (){ var todaysDate = new Date(); // Gets today's date var year = todaysDate.getFullYear(); // YYYY var month = ("0" + (todaysDate.getMonth() + 1)).slice(-2); // MM var day = ("0" + (todaysDate.getDate() +1 )).slice(-2); // DD var minDate = (year +"-"+ month +"-"+ day); // Results in "YYYY-MM-DD" for tommorrow's date // Now to set the max date value for the calendar to be today's date $('.calendarDate2 input').attr('min',minDate); }); });
My goal is to have just one date field, and then using the JavaScript, automatically choose the appropriate date restrictions based on if its before noon, or after.
Thanks for any help!