jetpack icon indicating copy to clipboard operation
jetpack copied to clipboard

Contact Form: Custom Date Format

Open ntpixels opened this issue 10 years ago • 4 comments

The "Date" field was added to contact forms through issue #269: [contact-field label='Pick a date' type='date'/]

Currently the date is hard coded to show as yy-mm-dd once it is chosen in the form's calendar, as shown in the following code: https://github.com/Automattic/jetpack/blob/master/modules/contact-form/js/grunion-frontend.js

Instead, would it be possible to allow a choice in the format of the date shown? For example, Month DD, YYYY.

ntpixels avatar Mar 23 '16 17:03 ntpixels

Requested in 2593714-t

ntpixels avatar Mar 23 '16 17:03 ntpixels

Related: https://api.jqueryui.com/datepicker/#option-dateFormat

jeherve avatar Mar 23 '16 17:03 jeherve

This is currently using an HTML date input field, in addition to loading a jQuery datepicker UI on top.

Regarding date input fields, according to Mozilla:

One thing to note is that the displayed date format differs from the actual value — the displayed date format will be chosen based on the set locale of the user's operating system, whereas the date value is always formatted yyyy-mm-dd.

It appears that date input fields require a yyyy-mm-dd format, and this is not configurable (since the browsers do it automatically for you).

#7819 offers a solution to clear up the duplicated datepicker UI by using jQuery only as a fallback for legacy browsers without date input field support. In this case, I think leaving jQuery to follow the same format as the default date input field is the best option - especially over time as these browsers become obsolete and the jQuery backup is no longer needed.

rclachance avatar Sep 20 '17 04:09 rclachance

Fixed in #7819

jeherve avatar Sep 26 '17 20:09 jeherve