# Remove text from textbox

**URL:** <https://discourse.psychopy.org/t/remove-text-from-textbox/30772>\
**Category:** Builder\
**Tags:** pavlovia\
**Created:** [September 9, 2022, 4:33pm UTC](https://discourse.psychopy.org/t/remove-text-from-textbox/30772 "2022-09-09T16:33:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Serena](https://avatars.discourse-cdn.com/v4/letter/s/a87d85/32.png) [@Serena](https://discourse.psychopy.org/u/Serena)\
**Post date:** [September 9, 2022, 4:33pm UTC](https://discourse.psychopy.org/t/remove-text-from-textbox/30772/1 "2022-09-09T16:33:42Z")

</div>

Hello everyone,

In my experiment, I am using the textbox option throughout my experiment. At the beginning of the experiment, I ask questions, and in the textbox, it has the text “type here” so participants know where to type.

I was wondering if there is any way that Psychopy can remove the text after participants saw it just so when they type in their responses, the data come out cleaner. I don’t want to see the “type here” text on the excel file for every participant.

Thank you

---

<div class="post-metadata">

**Author:** ![ajus](https://avatars.discourse-cdn.com/v4/letter/a/dc4da7/32.png) [@ajus](https://discourse.psychopy.org/u/ajus)\
**Post date:** [September 12, 2022, 6:57am UTC](https://discourse.psychopy.org/t/remove-text-from-textbox/30772/2 "2022-09-12T06:57:26Z")

</div>

Hi @Serena, for clarification: Is this the same routine containing this textbox that gets reused / looped during the experiment, or are you talking about different routines with different textboxes?

---

<div class="post-metadata">

**Author:** ![TParsons](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/tparsons/32/8301_2.png) [@TParsons](https://discourse.psychopy.org/u/TParsons)\
**Post date:** [September 12, 2022, 10:18am UTC](https://discourse.psychopy.org/t/remove-text-from-textbox/30772/3 "2022-09-12T10:18:33Z")

</div>

You could use a :code: Code component with the following in its “Each Frame” tab to make it so that a textbox with only the start text in it clears its contents when it receives focus (aka when the caret starts flashing and it starts receiving text input):

```auto
if textbox.hasFocus and textbox.text == "Type here...":
    textbox.text = ""

```

Then just set the text value of that textbox to be Set Every Repeat and be `Type here...` so that it resets to the start text each repeat.

The issue with this would be that there always has to be one object which has focus, so if you only have one editable textbox on screen then it will have focus from frame 0 and so the start text won’t be visible. But if you wanted to implement a grace period of 1s you could set the textbox to be non-editable and do:

```auto
textbox.editable = t > 1
if textbox.hasFocus and textbox.text == "Type here...":
    textbox.text = ""

```

---

<div class="post-metadata">

**Author:** ![simtib](https://avatars.discourse-cdn.com/v4/letter/s/90ced4/32.png) [@simtib](https://discourse.psychopy.org/u/simtib)\
**Post date:** [July 9, 2024, 7:16pm UTC](https://discourse.psychopy.org/t/remove-text-from-textbox/30772/4 "2024-07-09T19:16:23Z")

</div>

I am interested to implement such option in javascript. It looks like the python/JS translation is not working. My guess is that textbox.hasFocus needs to be coded a specific way in javascript.
