asked on April 2, 2020
I am looking for some help to prevent users entering future dates. I have used some code in a previous post t, but my Date fields are in a Table and also a Collection. The first record it works well, but when I add a row any additional rows do not work for the Date field.
Thanks
Grant
// Prevent Future Dates from being Entered
$(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 maxDate = (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
$('.PastCourseDate input').attr('max',maxDate);
});
});
0
0