Custom ValidationMessages for minDate/maxDate

I have tried the following, but the html5 validation still shows the default browser error. Do i need to about it differently?
DatePicker::configureUsing(function (DatePicker $datePicker) {
return $datePicker->minDate(Carbon::createFromDate(1500, 1, 1))
->maxDate(now()->addYears(9))
->validationMessages([
'after_or_equal' => 'The :attribute must be after January 1, 1500.',
'before_or_equal' => 'The :attribute cannot be more than 9 years in the future.',
]);
});
DatePicker::configureUsing(function (DatePicker $datePicker) {
return $datePicker->minDate(Carbon::createFromDate(1500, 1, 1))
->maxDate(now()->addYears(9))
->validationMessages([
'after_or_equal' => 'The :attribute must be after January 1, 1500.',
'before_or_equal' => 'The :attribute cannot be more than 9 years in the future.',
]);
});
4 Replies
Mark Chaney
Mark ChaneyOP11mo ago
actually i think this is now working. hmm, i need to double check. i Know my macro version is at least working for a different requirement set. Need to double check this global one
Mark Chaney
Mark ChaneyOP11mo ago
Hmm, sometimes the below the field validation shows and other times its the html5 version with
No description
Sins Tyson
Sins Tyson2mo ago
@Mark Chaney did you find out? and is it possible to format the date on the error message?
Sins Tyson
Sins Tyson2mo ago
Using Mozilla
No description

Did you find this page helpful?