News for hackers. Stuff that matters.
Re:HTML Form Validation is heavily underused by Sander_Marechal on Tuesday October 29, 2024 @05:08AM (#41981154)
The native date input is terrible. Not the actual native control, which is usually okay, but the field itself. You can't even format the date! That's the number one reason I always use some datepicker library in combination with a regular text input.
Re:HTML Form Validation is heavily underused by otherme123 on Tuesday October 29, 2024 @06:06AM (#41981894)
IMO, you (the web developer) should not be formatting the date shown in the input widget. The input should be shown to the client following the system settings, so a US browser would show MMDDYYYY, while an European browser would show DDMMYYYY. And the field is correctly (IMO) normalizing all of them to ISO-8601 (YYYYMMDD) before sending it back.

And I have this opinion because I had to deal before with format configuration and normalization before saving to the database, when using a JS library. Now I just drop a "input type=date", and I know I'm going to get the ISO formatted date at the backend.

Re:HTML Form Validation is heavily underused by Sander_Marechal on Tuesday October 29, 2024 @07:28AM (#41982770)
If my entire application used YYYY-MM-DD everywhere, it can be very confusing for users when the input suddenly uses something else. And often the locale or system settings are incorrect anyway. When I an working on a Dutch site with a Dutch locale and lang settings, then dates should be shown according to the Dutch locale, not according to whatever system of browser locale there is.

I always keep my OS and browser in English (makes searching for error messages sooo much easier) but I hate that I need to change my OS settings just to get Firefox to display the date in a proper way on some site.

Re:HTML Form Validation is heavily underused by otherme123 on Tuesday October 29, 2024 @09:07AM (#41983467)
If it works for you, I guess it's OK.

My apps usually deal with non-technical people (thus ISO in the browser input is out of the question), and sometimes spread at least between Europe and US (so people would enter MMDDYYYY and DDMMYYYY, and keep in mind that some dates work validate for both formats, namely every 12 first days for each month). Behind the scenes everything is ISO and UTC, but everyone gets their preferred format in the frontend.

I'm not getting your Dutch example. If I'm in the US and use MMDDYYYY almost always, and want to access some Dutch site, what date format would you show me in the input form? DDMMYYYY only because the backend is hosted in Europe? You will get wrong dates (e.g. 11/1/2024 for the first day of november, your system will store 11th of january) for at least half the US visitors.

Or maybe you are talking about "dates displayed" instead of "dates input", which is a different problem?

Re:HTML Form Validation is heavily underused by poincaredisk on Tuesday October 29, 2024 @09:37AM (#41983716)
To be honest I would expect dates on a Dutch site to be shown in dutch format, just like I expect dates on American sites to be formatted in the US way.
Re:HTML Form Validation is heavily underused by wadadadad on Tuesday October 29, 2024 @11:15AM (#41984699)
How do we know when a site is Dutch? Maybe check the URL to see if the TLD indicates?

I'm in agreement with showing/inputting dates in the users' regional setting.

Re:HTML Form Validation is heavily underused by Sander_Marechal on Tuesday October 29, 2024 @11:49AM (#41985387)
<html lang="nl_NL"> of course
Re:HTML Form Validation is heavily underused by otherme123 on Monday November 04, 2024 @04:59AM (#42040061)
Lets clarify a bit here. There are two different problems:

- Date display. I prefer to show it in the browser preferred format, but in the end what you say is also OK. It's a very minor issue.

- Date input. I would never force a format to the user, it there is any chance people from different locales can access the web. The correct way, IMO, is "input in the preferred browser format, send data as ISO". Any other combination would cause errors, e.g. "input in the preferred browser format, send data in that format" and you'll get wrong dates in the backend, or need to do a lot of gymnastics to avoid them. "input in server locale, send data in any format", and you'll get wrong dates from people used to any format that is not your server locale that happens to validate in multiple locales. "input in ISO, data send as ISO", you'll get users upset because "YYYY-MM-DD is stupid, use MY locale instead".