Added functionality and validation to textfield