fix validation for text input
simplify the use of classes