added client side validation and error handling to form