Improve the logic and UI feedback for validating the input fields