added validation and message display on frontend