verbb / formie

The most user-friendly forms plugin for Craft CMS.
Other
95 stars 73 forks source link

Date field's pattern mismatch message is in the wrong format #1334

Open chrismlusk opened 1 year ago

chrismlusk commented 1 year ago

Describe the bug

I have a Date/Time field configured to present the date as MM/DD/YYYY, but I noticed while testing junk values that the error message is asking for YYYY-MM-DD.

date-error

Also, it seems that any year < 1900 or >= 2100 triggers the pattern mismatch error, FWIW.

Steps to reproduce

  1. Date/Time field → Appearance → set "Date Format" to "MM/DD/YYYY"
  2. On the front end, add a date with a year < 1900 or >= 2100

Form settings

Craft CMS version

4.3.10

Plugin version

2.0.23

Multi-site?

No response

Additional context

No response

engram-design commented 1 year ago

Just want to confirm if you're using the Date Picker (Flatpickr), or just the browser-native date input?

chrismlusk commented 1 year ago

I do have the Date Picker disabled. With it enabled, Flatpickr does its thing to normalize the value, so no error message. But, I would prefer not to use Date Picker.

engram-design commented 1 year ago

So the main issue with the non-Date Picker option is that this is a browser-native date input. The value shown is constrained to match the users browser language setting. From what I can tell, there's no way to change this. This is where Flatpickr comes in for a cross-browser and feature-rich date picker.

As for the client-side validation message that's being shown, that would be bouncer.js's interpretation of what an invalid date is. The error message could maybe do some tweaking to a generic "Please provide a valid date", but it indeed does match only years 1900-2099. I suppose it's only a problem we have to maybe deal with in 77 years.