added validation only when clicking submit