Imagine a dropdown list with search features where I can type or paste some text. What will be the best way to validate my dropdown:

  • A: Comparing the text with the database text after click outside the box
  • B: Clear the dropdown if the user doesn't click on something in the search list

2 Answers 2


I definitely wouldn't just clear the box, that could be confusing for some users. Validate and explain the error as needed. You could even use the dropdown itself for validation, and display an error message in lieu of results.


Neither of them : clearing edit box goes no where , it just causes the user to re-enter the text. Clicking outside the box : why outside ? Consider validating the input on pressing ENTER key .

Best regards.

  • 1
    You use the onbur JS event to trigger the inline validation as you exit the field, either by clicking anywhere else on the page, or pressing the TAB keyboard key. Pressing the ENTER key should trigger the whole form submission.
    – SteveD
    Commented Aug 1, 2016 at 14:56
  • Oh , sorry :) .
    – DrWael
    Commented Aug 1, 2016 at 15:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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