Added validation for input fields.