Set cursor position and selection on input fields