Refactored js/added validation in to client as well