How to get rid of an error message when click on reset button