What's the best approach to get Date/Time input from the user?

Ryan picture Ryan · Feb 23, 2009 · Viewed 7.1k times · Source

This is a wheel that's been re-invented again and again over the years.

The Problem: The user needs to input a Date/Time

Basic considerations

  • We want to make it as easy as possible for the user to enter the desired date/time
  • Some applications call for historical dates, some applications call for future dates only, some will need to handle both
  • We want to prevent the user from entering jibberish data
  • We want to auto-populate this control as aggressively as possible.
  • We want this control to be as re-usable as possible.

Popular solutions include:

  • Text Boxes
  • Combo Boxes
  • Pop-out calendars
  • Server-side and/or client-side validation
  • Various ways of alerting the users about bad data

There are a panoply of ready-to-eat solutions about, but I'm looking for some more general information. Have there been any usability studies done on the various date-time-control approaches? Is there a "best" date-time control out there? Are there any well-established "Dos and Don'ts"?


Related question: Best GUI control(s) to describe a time range

Answer

anon picture anon · Feb 23, 2009

My preference is for a text input with an elipsis button next to it:

Enter a date [        ] [...]

The elipsis would pop up a calendar to populate the text input, but the user can type in a date if they want. Validation should be done when the "OK" button for the form is pressed - trying to do date validation on a character by character basis is doomed, in my experience.

The validation should be sophisticated and allow expressions like

"today"
"Tomorrow"
"23 Jan"

etc.

Edit: In reply to some comments, one could do validation when the text edit loses focus (though I hate that kind of thing) in which case the edit content could change from "23 Jan" to "23-01-2009" to indicate that the exprssion was understood.