2

I am working on an Android app (we also have an iOS and a web version) and I am currently adding validation to a view where the user can select a time range. I am wondering if there are any conventions (or tips) on how the validation should work. I guess this question is applicable to other types of ranges as well.

There is one field for start time and one for end time (hour and minutes, entered differently depending on platform and localisation settings). The start time must be (strictly) less than the end time. There is also a lower and an upper limit to both values since the time range is within one day.

beginning of day <= start time < end time <= end of day

Both the fields have valid default values but I wonder how I should handle the case when the user tries to set an invalid value. These are some actions I have in mind (possibly combined):

  • Set field to previous (valid) value.
  • Set field to closest valid value.
  • Display an error message.
  • Disable the save button.
  • If setting start >= end, set end to lowest valid value (and/or vice versa)
  • If setting start >= end, make the user select a new end value (and/or vice versa)

Any suggestions?

  • Is it invalid only when end < start? If you're using some sort of time picker control, validating that your time is between start and end of day shouldn't be an issue. Are there other ways it can be invalid? – Broots Waymb Mar 30 '16 at 13:54
  • The start time is invalid if it is less than the minimum allowed value (constant) or it is greater than or equal to the end time. The end time is invalid if it is greater than the maximum allowed value (constant) or it is less than or equal to the start time. The question is not how to determine if a value is invalid but how an invalid value should be handled. – LoPoBo Mar 30 '16 at 14:19
1

The best solution is to prevent users from entering an invalid range. You can use date pickers that disable all invalid dates.

Alternatively if the above solution is not possible, I suggest the following:

  • Keep the date the user entered, do not modify it in any way. Any automatic change on the date will be confusing and error prone.
  • Display an error message near the date range, modeless if possible.
  • Disable the save button.
  • 1
    I can't disable the values in the pickers (without some costs) but I went with the other half of your solution. – LoPoBo Apr 8 '16 at 7:55
0

Do you care about minutes/seconds?

From a user perspective it would be much easier if they can tap on slots to select the area they want you to cover. Similar to creating a new meeting in a calendar you can tap - then expand your selection.

If you must just show numbers then : - if the user selects an end time that's less than start time : change start time to = end time.

E.g. user selects 11AM start time, user selects 10 AM end time. You show both at 10AM and you can display: "That gives you no time to do this, Try again" or something of sorts

For the "Beginning of the day"/"End of the day" Ranges I suggest you don't give them the option to pick something from the previous day so you won't have that problem anymore.

  • Thanks for your input but I decided to not make any automatic changes and simply display an error and disable the save button. – LoPoBo Apr 8 '16 at 7:53
0

Have you considered simply swapping the values in the event of the end coming before the start? That would remove the need to negate the user's action. They would simply select two dates and that would be the time span.

  • I think swapping values could be confusing in many situations. For example, if the interval is [1, 2] and the user wants to set [3, 4] and begins by setting the start time to 3, the interval would become [2, 3] and he would have to set the start time (again) to 4. – LoPoBo Apr 8 '16 at 7:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.