To avoid problems with this particular form, we need to have the dates on our calendar only allow today's date and future date. Am I missing something that allows you to keep the calendar from allowing dates before
"today's date?" Any help would be really appreciated!
Question
Question
How do I set the calendar to not allow dates before today's date?
asked on August 14, 2015
1
0
Answer
SELECTED ANSWER
replied on August 14, 2015
Hello James,
Here is a solution using javascript taken from this thread https://answers.laserfiche.com/questions/75138/I-want-to-prevent-user-from-picking-a-date-greater-than-today and modified.
For note, I have named my calendar class "calendarDate" as shown in the image below
From there, I have modified the javascript from the thread to only allow dates today and after.
$(function() { $(document).ready(function () { var todaysDate = new Date(); // Gets today's date // Max date attribute is in "YYYY-MM-DD". Need to format today's date accordingly 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 today's date // Now to set the max date value for the calendar to be today's date $('.calendarDate input').attr('min',minDate); }); });
6
0
replied on September 21, 2015
What change would I need to make to this if I didn't want to allow and future dates?
0
0
replied on September 21, 2015
If you're talking about wanting to allow past dates up to the current date and not allow future dates, then using the same code sample in the solution provided, just change
$('.calendarDate input').attr('min',minDate);
to
$('.calendarDate input').attr('max',minDate);
You may want to change the variable name as well to avoid confusion.
2
0
replied on September 22, 2015
Awesome, thank you!
0
0