Home Forums Front-end Issues javascript maxdate Reply To: javascript maxdate

  • The problem is something that the developer is going to need to fix, but I can summarize what is happening and maybe that can help you figure out a way around the problem.

    The problem is caused by a difference in the display format vs the storage format. ACF always stores dates as yymmdd.

    When ACF sets up the date picker field it initially sets it up using the storage format for the date for the display format and then it changes it back to your display format. This switching in the display format is what is causing the min and max dates to go awry. This happens even if the storage format and the display format are the same. Something about changing the display format after you’ve set the min and max dates screws up both of these values. I actually suspect that it has something to do with the jQuery datepicker and how it recalculates the dates rather than something in ACF. (you’d need to try it on a field not controlled by ACF to know for sure)

    Unfortunately, altering how ACF initializes the datepicker field causes and error in the way that the date is saved in the database, so there is no quick fix for this in ACF.

    The only idea that I can come up with would be to add an onFocus action to the date field and set the min and max dates then instead of by setting the values when ACF is setting up the field. Honestly I don’t even know if that will work, or even how to go about doing it.