Dropdown with search features validation

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 don't click in something in the search list