# Text Selected onFocus

**URL:** <https://forum.kirupa.com/t/text-selected-onfocus/229765>\
**Category:** flash\
**Created:** [June 20, 2007, 1:51am UTC](https://forum.kirupa.com/t/text-selected-onfocus/229765 "2007-06-20T01:51:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![bandit8](https://avatars.discourse-cdn.com/v4/letter/b/c6cbf5/32.png) [@bandit8](https://forum.kirupa.com/u/bandit8)\
**Post date:** [June 20, 2007, 1:51am UTC](https://forum.kirupa.com/t/text-selected-onfocus/229765/1 "2007-06-20T01:51:18Z")

</div>

Hi,

I have 2 input text fields in my movie…each has prepopulated text, giving directions to the user. i.e. the first input field is for their first name, and is populated with the text “First name here…”

I want it so that when the user clicks in the first name text field, the text is automatically selected, so that they can easily hit delete and get rid of it all, or even just start typing and have their content replace the initial text.

This is what I am trying…

```auto
nameTxt.onSetFocus = function(){
    nameTxt.setSelection(0,nameTxt.length);
    trace("focus is set on name "+nameTxt.length);
}

```

The trace is there just to prove that is actually recognizing that the focus is set on that field… its just not selecting the text.

Any thoughts?

Thanks!  
b.
