Why the input field is not working based on the condition?