Added validation and proper error handling in registration form.