I'm trying to disable all dates in the future in the pop-up date field. I'm trying this code:
$(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 $('.InfDate input').attr('max',maxDate); }); });
found from this question. But for some reason it isn't working. Would anyone be able to help? I've made the CSS class for the date picker "InfDate". I changed the format to match YYYY-MM-DD. But ideally I would like to change it back to MM/DD/YYYY.
Thanks,
David