0

For example, right now, to be able to continue when pressing a button the following things should happen:

  1. An input text box should not be empty.

  2. Internet connection should be active.

  3. Date should be the current one.

Would it be better if I display a message telling all errors that have been found or tell one of them every time the user presses the button?

I'm better explaining it:

My idea is to either show 1 or more snackbars that either tell about one of these problems one per one, or these snackbars that show all together.

The code structure for the first case would be something like.

if (noemptytext)
{
    if (internetActive)
    {
        if (correctDate)
        {

        }
        else
        {
            showSnackBar(wrongdatemessage);
        }
    }
    else
    {
         showSnackbar(nointernetmessage);
    }
}
else
{
   showSnackbar(emptytextmessage);
}

And for the second case:

String messageAllErrorsFound="";

if (emptytext)
{
    messageAllErrorsFound+=emptytextmessage
}

if (nointernet)
{
    messageAllErrorsFound+=nointernetmessage
}

if (wrongDate)
{
    messageAllErrorsFound+=wrongdatemessage
}

if (!messageAllErrorsFound.equals(""))
{
    showSnackbar(messageAllErrorsFound);
}
2
  • Could you provide a little more context about what your user is doing? A good way to answer this would be to use an agile user story. A user story is short, specific and goal-oriented. It is a one-sentence statement that tends to have the following structure: “As a , I want so that ”. That being said, it appears that you want to apply form validation best practices. Rather than trying to explain the best approach here, this is a great resource to help you get it right. smashingmagazine.com/2009/07/… May 11, 2021 at 10:42
  • You'd better share the screenshots of the exact medium and how the interface looks like other than the code. May 12, 2021 at 8:44

1 Answer 1

3

According to Material Design guidelines, it's best to select a feedback pattern based on its urgency:

Low Urgency Component: Snackbar. Optional: Snackbars disappear automatically

Medium Urgency Component: Banner. Optional: Banners remain until dismissed by the user, or if the state that caused the banner is resolved

High Urgency Component: Dialog. Required: Dialogs block app usage until the user takes a dialog action or exits the dialog (if available)

In your example, 1 and 3 are field validation errors (low urgency), which are best to communicate inline near each affected field. You can use a snackbar at the top to tell the user to review all errors. Example:

Error message inline near an affected field, with optional header message

2 is a different problem with a higher level of urgency. If the user can still operate offline, it's medium urgency and a banner can be used (with a Retry link). If the user can't move forward (sounds like this is the case), use a dialog to halt the submission and break their attention until they fix the issue (Retry is a good option here, too).

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