Improvements on text field validation