Created
September 12, 2023 12:12
-
-
Save luiskabes-arch/896f8841df5641abbfec4b875a3a6bd0 to your computer and use it in GitHub Desktop.
Change flatpickr config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Change flatpickr config on Vacancy form | |
let calendar = $('#ff_5_birth, #ff_9_birth').get(0)._flatpickr; | |
if (calendar) { | |
let currentDate = new Date(); | |
let maxDate = new Date(currentDate.setFullYear(currentDate.getFullYear() - 18)); | |
// Convert minDate to 'd M Y' format | |
let maxDateString = maxDate.getDate() + ' ' + maxDate.toLocaleString('default', { month: 'short' }) + ' ' + maxDate.getFullYear(); | |
calendar.set("dateFormat", "d M Y"); | |
calendar.set("maxDate", maxDateString); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment