method to handle text field input