What is recommended to handle the scenario "User entered empty/null" value in the search bar. Its in eBook.

Just want to know the genius way to handle apart from providing the error message like "Enter some search text"

  • Clarifying if I understand your question correctly: are you asking what is the recommended user experience when the user doesn't type any text inside a search textbox and presses enter (or the search button)?
    – staccato
    Dec 11, 2017 at 16:46
  • yes @staccato.. Exactly. When a user enters null value in the search bar and presses enter, what could be the best approach to handle the situation in terms of user experience.
    – A user
    Dec 11, 2017 at 16:50
  • The error message should say: "You can't have everything. Where would you put it?"
    – user67695
    Dec 11, 2017 at 17:09
  • haha.. +1 for this. sounds humour though.
    – A user
    Dec 12, 2017 at 13:40

2 Answers 2


There could be two possible solutions.

  1. Keep the button disabled and let the user know when he try to hit the button using alert/popover/error message
  2. Keep the button active but do nothing if a user hit submit but show error message.

Check being a user what would you expect in that scenario?

  • 1
    For the record, I would highly recommend the second approach, as, the first relies on the user taking some action (even if it is just a hover) on a button that is visibly disabled. If they don't take that action, they will never know why the button is disabled.
    – talemyn
    Dec 11, 2017 at 21:16

Use a Snackbar (Toast) to show a message.

Snackbars (toasts) are often used as tooltips/popups to show a message at the bottom of the screen, that fade out within seconds.

Learn how to create a snackbar / toast with CSS and JavaScript.

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.