Reputation: 11265
In my current date form input, I have the parameter:
'maxYear' => date('Y')
This lets me limit the max year to this year, but I also need to limit the date selection so users cannot select a date in the future. Using maxYear
only allows limiting the year, but I also need months and days.
Upvotes: 1
Views: 1285
Reputation: 29121
That's not something you can do with the Form Helper (or the HTML form options even if you'd wrote them manually).
The problem:
If you limit the month to say, 1-7 (if we're currently in July), the user would be unable to select the previous year of any of those months.
The solution:
Use JavaScript onchange
validation. When the field(s) change date, check the selected date against your required date range, and give notification if it fails. (see jQuery's .change()
documentation if you're using jQuery)
(Then verify on the back-end, as well of course, as JavaScript can easily be manipulated)
Upvotes: 2