Input Date type with year containing 6 digits

Asked

Viewed 691 times

8

Look at the snippet just below, that the input of the kind date when typed in the value year, it is possible to insert 4, 5 or 6 digits to be exact:

<input type="date">

My doubts are exactly:

  • For what purpose the year can be more than 4 digits?
  • If there is any purpose for it, how could it be applied?

I know that when using the attributes min and max, automatically the year can only receive 4 digits, so why the default value of the year can receive up to 6?

  • 2

    It only passes in my mind temporal scalabillity.

  • 2

    Particularly, I find the input type "date" mt bad. I would use 3 separate fields type "number", one for each information: day, month and year. Or a select for each.

  • depends on the application you are developing. in the vast majority of cases it does not make sense to have more than 4 digits, but it goes that someone develops a platform/game that has as theme the years to come. far-fetched but I don’t know

1 answer

7


For me it’s just a bad one pattern. Of course a year can have 5 or 6 digit values for some scenarios (not exactly within the pattern (standard) universal), but no one works with this, the default browser should be the one that most people use and at the moment it is 4 digits (it was already 2 and could be back) and the standard ISO 8601 clearly says it should be 4 (giving the freedom to be more, which to me is a bad freedom because it doesn’t have a fixed pattern, but it adopts a number that makes more sense).

But note that limiting the minimum and maximum that can be entered nothing changes in Firefox, even if you boot with a value off. Of course, at the end of the typing it will be considered invalid, but works with 6 digits. Try it:

<input type="date" value="111111-08-09" min="2019-01-01" max="2019-12-31">

I put in the Github for future reference.

Solution to this at the FF? There may be something simple (I don’t think so, it’s full of wrong answers out there), but I think the current solution is to make your own work right.

In fact was considered a bug in Chrome And so they changed, but they thought they couldn’t change more radically because specification doesn’t tell you to do this, and if you do it and one day specification tells you to do something else, they have something incompatible. Let’s wait for the FF to fix it (wants to open one Issue?). I don’t know about Safari.

And the specification may not change because it can create an incompatibility in some browser that has done something else, creating a deadlock :). Web is one of the worst computer inventions for precisely these things, the idea is good, the implementation is terrible. They’re worried about accessibility when even the basics don’t work right.

  • Really Maniero, had not yet tested in Firefox, even with min and max the value can still receive 6 digits, is it safe to use these types of fields, I say in an application with due date for example, will the guy can not do something maliciously by browser?

  • 3

    Malicious not because after all you validate the data on the server always, right? But it is a bad UX.

  • 3

    It seems implementation problem even, at first I thought it could be something linked to the date format, but it seems that not...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.