4 ms·
Now it seems the date picker, like the Safari one, is just meant to let you pick a recent date; for a faraway date like DOB, the weekday does not actually matte
by chazeon 4y ago
Now it seems the date picker, like the Safari one, is just meant to let you pick a recent date; for a faraway date like DOB, the weekday does not actually matter, so it is easier to ask the user to type. Just some quick thoughts after reading the article and comments.
- culi 4y agoThe date picker only defaults to today's date if they don't specify a default value. Tbh I think setting a default value might actually have been a better solution. It's not perfect, but hacking together your own alternative could lead to a number of issues for folks relying on screen readers and other input devices. The `type="date"` gives a lot of semantic meaning that `type="number"` lacks. If you're gonna ditch it, I'd say at least use an existing external library that's been battle tested for accessibility.
- pishpash 4y agoWhat would a default birthdate be? That would span 80+ years. That's not going to work. Any time an input spans ~29k values, you better provide some logarithmic-time searching mechanism. So yes, Safari's date picker is f'ing dumb.
- culi 4y agoWhich of these do you think did it better? https://wd.imgix.net/image/vvhSqZboQoZZN9wBvoXq72wzGAf1/uh0U2YQnUMato21MzzbR.png?auto=format https://wd.imgix.net/image/vvhSqZboQoZZN9wBvoXq72wzGAf1/uh0U... From left to right, that's Chrome desktop, Chrome mobile, Safari desktop, Safari mobile, and Firefox desktop --- The post specified that the users are mostly senior. Regardless of what they go with clearly 0% of their users benefit from leaving it to default today unless they somehow figured out how to sell smartphones to fetuses
- phillipseamore 4y agoAlso depending on the product and legal requirements the latest possible DOB might be 13, 18 or more years ago.
- Joeri 4y agoIf a default value is set you’re going to have the problem of people skipping the field and submitting the default value instead. What is needed is a way of influencing the picker’s default view into year view with a default year visible, but without actually setting a default value. Only Apple can provide that level of control.
- snowwrestler 4y agoThere is always a default value in a picker; if you don't specify one, the UI defaults to today's date.
- mcintyre1994 4y agoYou’re talking about slightly different things. You’re right that when the UI opens it’s always going to be on a default date, if you don’t set one it’ll be today. But if you don’t set one then the value of the HTML element will be null before it’s selected. So if you add a required attribute then you can make sure that your users use the date picker (or leave in frustration after failing to do so) before submitting the form. If you set a default value using the value attribute, then that becomes both the HTML default value and the UI default. IMO the spec is missing a way to just set the UI default, so that the field is default empty but interacting puts it at a sensible starting point. There’s an MDN example here where the date starts empty and is required, if you try submitting the form you’ll see there’s no default for the HTML element: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/date#validation https://developer.mozilla.org/en-US/docs/Web/HTML/Element/in...
- culi 4y agoHmmm, yeah I suppose that's true when using the `value` attribute, EDIT: ignore the below. It was pointed out I misinterpreted defaultValue. but there's actually also a `defaultValue` attribute which I believe behaves how you would like it to: https://caniuse.com/mdn-api_htmlinputelement_defaultvalue https://caniuse.com/mdn-api_htmlinputelement_defaultvalue Ofc you can also use JS to make sure an input has been blurred or touched to pass validation on submit