# Clearing textfield.text

**URL:** <https://forum.inductiveautomation.com/t/clearing-textfield-text/33301>\
**Category:** Ignition\
**Created:** [March 22, 2020, 8:20pm UTC](https://forum.inductiveautomation.com/t/clearing-textfield-text/33301 "2020-03-22T20:20:14Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![dcamp1](https://avatars.discourse-cdn.com/v4/letter/d/dc4da7/32.png) [@dcamp1](https://forum.inductiveautomation.com/u/dcamp1)\
**Post date:** [March 22, 2020, 8:20pm UTC](https://forum.inductiveautomation.com/t/clearing-textfield-text/33301/1 "2020-03-22T20:20:14Z")

</div>

I’m trying to setup a textfield to allow the user to input some data, this all works just as I would expect, except once the data has been added by an “Add Button” how do I clear the textfield.text so it will be blank for the next input of data?

---

<div class="post-metadata">

**Author:** ![etlikmilos](https://avatars.discourse-cdn.com/v4/letter/e/fbc32d/32.png) [@etlikmilos](https://forum.inductiveautomation.com/u/etlikmilos)\
**Post date:** [March 22, 2020, 8:42pm UTC](https://forum.inductiveautomation.com/t/clearing-textfield-text/33301/2 "2020-03-22T20:42:00Z")

</div>

I use this for cleaning text field

```auto
self.getSibling("Label").props.text = ""

```

---

<div class="post-metadata">

**Author:** ![dcamp1](https://avatars.discourse-cdn.com/v4/letter/d/dc4da7/32.png) [@dcamp1](https://forum.inductiveautomation.com/u/dcamp1)\
**Post date:** [March 22, 2020, 8:45pm UTC](https://forum.inductiveautomation.com/t/clearing-textfield-text/33301/3 "2020-03-22T20:45:52Z")

</div>

OK, I will try that. How would you test to make sure textfield is NOT Blank.

---

<div class="post-metadata">

**Author:** ![etlikmilos](https://avatars.discourse-cdn.com/v4/letter/e/fbc32d/32.png) [@etlikmilos](https://forum.inductiveautomation.com/u/etlikmilos)\
**Post date:** [March 22, 2020, 9:06pm UTC](https://forum.inductiveautomation.com/t/clearing-textfield-text/33301/4 "2020-03-22T21:06:21Z")

</div>

Like this ?

```auto
empty = self.getSibling("TextField").props.text
	if empty == "":
	       self.getSibling("TextField").props.text= "YES"
	else:
	      self.getSibling("TextField").props.text ="NO"

```

---

<div class="post-metadata">

**Author:** ![dcamp1](https://avatars.discourse-cdn.com/v4/letter/d/dc4da7/32.png) [@dcamp1](https://forum.inductiveautomation.com/u/dcamp1)\
**Post date:** [March 23, 2020, 1:10am UTC](https://forum.inductiveautomation.com/t/clearing-textfield-text/33301/5 "2020-03-23T01:10:32Z")

</div>

Thank You!

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [March 23, 2020, 5:04am UTC](https://forum.inductiveautomation.com/t/clearing-textfield-text/33301/6 "2020-03-23T05:04:22Z")

</div>

```auto
self.getSibling("TextField").props.text == ""

```

Only tests for empty Strings.

```auto
# This following code also checks to make sure that the property value is not None.
# In the previous snippets in this thread, a None value would have evaluated as text being present.
displayed_text = self.getSibling('TextField').props.text
if displayed_text and len(displayed_text) > 0:
    # There IS text

```

---

<div class="post-metadata">

**Author:** ![epifanio.tigno](https://avatars.discourse-cdn.com/v4/letter/e/57b2e6/32.png) [@epifanio.tigno](https://forum.inductiveautomation.com/u/epifanio.tigno)\
**Post date:** [March 23, 2020, 6:44am UTC](https://forum.inductiveautomation.com/t/clearing-textfield-text/33301/7 "2020-03-23T06:44:35Z")

</div>

value = u’’  
event.source.parent.getComponent(‘Text Field’).text = value

Try this to your ADD BUTTON and it works for me

---

<div class="post-metadata">

**Author:** ![dcamp1](https://avatars.discourse-cdn.com/v4/letter/d/dc4da7/32.png) [@dcamp1](https://forum.inductiveautomation.com/u/dcamp1)\
**Post date:** [March 23, 2020, 9:45am UTC](https://forum.inductiveautomation.com/t/clearing-textfield-text/33301/8 "2020-03-23T09:45:08Z")

</div>

Very well done and complete. Thank you.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [March 23, 2020, 3:38pm UTC](https://forum.inductiveautomation.com/t/clearing-textfield-text/33301/9 "2020-03-23T15:38:44Z")

</div>

> [@cmallonee](#):
>
> `if displayed_text and len(displayed_text) > 0:`

Or just `if displayed_text:`, because an empty string is already 'falsey' in Python 🙂
