How to conditionally show error message on the form?