How can I make the date picker (or a date field in general) only accept dates from today onwards - Refusing all dates before today?
Thanks
Only accept future dates (v2023)
-
- User
- Posts: 153
- Location: UK
Only accept future dates (v2023)
-
- User
- Posts: 153
- Location: UK
The problem seems to be getting todays date in a format TimePicker likes in the Advanced-Fields options. Reading all those posts, people have used
"minDate":today (today undefined)
"minDate":Moment() (Moment is not defined)
"minDate:Date() (Using string for date error)
I've tried all these both with {restrictions{"minDate":Moment()}} and with {"minDate":Moment()} and I get the same errors with both
(The former seems to be what the TP documentation says but none of the posts here mention it.)
I'm sure this must be something stupidly simple, but what??
Thanks
-
- User
- Posts: 92
hello. hope this helps you with your concern.
$today = date("Y-m-d H:i:s");
$date1 = $this->date_filed->CurrentValue;
if ($date1 <= $today) {
$customError = "your custom error message";
return FALSE;
}
i have place this on the table specific->Add/copy page -> form_customvalidate
-
- User
- Posts: 153
- Location: UK
Thanks, but I was intending to make the date text box read-only so they had to use the DatePicker.
However I'm still stuck on getting today's date. Following ideas in other posts I've tried...
{restrictions:{"minDate":"today"}}
Unable to parse provided input: today, format: dd/MM/y
{restrictions:{"minDate":Moment()}}
Uncaught ReferenceError: Moment is not defined
{restrictions:{"minDate":moment()}}
Uncaught ReferenceError: moment is not defined
{restrictions:{"minDate":[]}}
Uncaught Error: TD: Could not correctly parse "" to a date for restrictions.minDate.
Any thoughts?