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)