add the validation logic on text input