Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option for different date format presented to user and used as input.value (or match Chrome & Firefox user-format/value-format behaviour out of the box) #47

Open
mkstix6 opened this issue Oct 23, 2018 · 1 comment

Comments

@mkstix6
Copy link

mkstix6 commented Oct 23, 2018

I'm having trouble implementing validation for a date field because this polyfill behaves differently to Chrome's and Firefox's date picker implementations.

[I'm British by the way, so I'm using dd/mm/yyyy as my human readable examples]

Chrome and Firefox will display the date to me in the format dd/mm/yyyy. But if you call .value on the input the result is in the format yyyy-mm-dd,
…makes sense for localisation (e.g. the British/U.S. date format differences).

Calling .value upon an input this polyfill is implemented on returns the date format as it is displayed to the user — as if the input was type="text".

I think because of this difference, the validation I'm using (Bootstrap4) balks at the date value.

For this polyfill, there is an option to choose the date format but it acts on both the user facing and value formats simultaneously.

jQuery UI's date picker has options for both altFormat and dateFormat which allow you to manage a user facing format and a value format. I don't agree with the naming of these options but they facilitate a flexible solution to this scenario.

If this is actually possible, apologies. Perhaps I can help write some documentation on how to implement it.

@marcpeabody
Copy link

Ran into this same problem. The value of input needs to be yyyy-mm-dd no matter what is displayed to users to be considered a true polyfill.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants