# How to work with text input

**URL:** <https://discourse.nodered.org/t/how-to-work-with-text-input/14282>\
**Category:** Dashboard\
**Created:** [13 August 2019 14:55 UTC](https://discourse.nodered.org/t/how-to-work-with-text-input/14282 "2019-08-13T14:55:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![amitn](https://avatars.discourse-cdn.com/v4/letter/a/fbc32d/32.png) [@amitn](https://discourse.nodered.org/u/amitn)\
**Post date:** [13 August 2019 14:55 UTC](https://discourse.nodered.org/t/how-to-work-with-text-input/14282/1 "2019-08-13T14:55:33Z")

</div>

I'm trying to create a dashboard that will worked with text input and a button  
and will trigger a function that will do something.  
I'm not able to find on which object the text is saved and I how am dealing it in the function.  
Also, is there a way that the function will be triggered only when the button is pressed?  
Is there a way that the button will be disable as long no data entered?

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [13 August 2019 15:02 UTC](https://discourse.nodered.org/t/how-to-work-with-text-input/14282/2 "2019-08-13T15:02:42Z")

</div>

If you posted your flow, it would be easier to help you...

But in general the dashboard nodes explain how the data is sent in the info panel of the node ( usually msg.payload)

If you use the form node it is only sent when the button is pressed

---

<div class="post-metadata">

**Author:** ![amitn](https://avatars.discourse-cdn.com/v4/letter/a/fbc32d/32.png) [@amitn](https://discourse.nodered.org/u/amitn)\
**Post date:** [13 August 2019 15:07 UTC](https://discourse.nodered.org/t/how-to-work-with-text-input/14282/3 "2019-08-13T15:07:55Z")

</div>

In basic this is how i want my flow to look like:

```auto
[{"id":"e5e03e58.27ca4","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"73623a38.af8454","type":"ui_button","z":"e5e03e58.27ca4","name":"","order":0,"width":0,"height":0,"passthru":false,"label":"button","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"","x":480,"y":700,"wires":[["4e2e9bd0.471994"]]},{"id":"da86512d.2f4bd","type":"ui_text_input","z":"e5e03e58.27ca4","name":"","label":"","tooltip":"","order":0,"width":0,"height":0,"passthru":true,"mode":"text","delay":300,"topic":"","x":460,"y":640,"wires":[["4e2e9bd0.471994"]]},{"id":"4e2e9bd0.471994","type":"function","z":"e5e03e58.27ca4","name":"","func":"\nreturn msg;","outputs":1,"noerr":0,"x":720,"y":700,"wires":[["54b13780.debd08"]]},{"id":"54b13780.debd08","type":"ui_text","z":"e5e03e58.27ca4","order":0,"width":0,"height":0,"name":"","label":"text","format":"{{msg.payload}}","layout":"row-spread","x":960,"y":720,"wires":[]}]

```

What I need to do inside the function?  
I don't want to add another form

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [15 August 2019 09:26 UTC](https://discourse.nodered.org/t/how-to-work-with-text-input/14282/4 "2019-08-15T09:26:30Z")

</div>

> [@amitn](#):
>
> I'm not able to find on which object the text is saved

So add a debug node after the text item. [Read this](https://nodered.org/docs/user-guide/messages)

> [@amitn](#):
>
> Also, is there a way that the function will be triggered only when the button is pressed?

Yes, only have 1 wire from the button to the function.

> [@amitn](#):
>
> Is there a way that the button will be disable as long no data entered

Read the built in help...  
_"Setting `msg.enabled` to `false` will disable the button."_

**Here is an example for you...**

```auto
[{"id":"b573f57d.6290e8","type":"ui_button","z":"67c3c9f9.a06c78","name":"","group":"1b214600.17935a","order":3,"width":0,"height":0,"passthru":false,"label":"Do stuff","tooltip":"","color":"","bgcolor":"","icon":"","payload":"textInput","payloadType":"flow","topic":"","x":280,"y":340,"wires":[["cc26e2d4.ffd35","b42b2908.665408"]]},{"id":"1330b995.eb0626","type":"ui_text_input","z":"67c3c9f9.a06c78","name":"","label":"","tooltip":"","group":"1b214600.17935a","order":1,"width":0,"height":0,"passthru":true,"mode":"text","delay":"100","topic":"","x":260,"y":280,"wires":[["7ba1f4df.b12a7c","2ffeee02.29d762"]]},{"id":"cc26e2d4.ffd35","type":"function","z":"67c3c9f9.a06c78","name":"my function that does stuff","func":"msg.payload += \" - payload modified in my function\"\nreturn msg;","outputs":1,"noerr":0,"x":470,"y":340,"wires":[["bcad70c7.b9db","a0241251.a9cc4"]]},{"id":"bcad70c7.b9db","type":"ui_text","z":"67c3c9f9.a06c78","group":"1b214600.17935a","order":2,"width":0,"height":0,"name":"","label":"Result: ","format":"{{msg.payload}}","layout":"row-left","x":720,"y":340,"wires":[]},{"id":"2ffeee02.29d762","type":"change","z":"67c3c9f9.a06c78","name":"","rules":[{"t":"set","p":"textInput","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":450,"y":280,"wires":[["fe2d6e02.ad949"]]},{"id":"7ba1f4df.b12a7c","type":"debug","z":"67c3c9f9.a06c78","name":"Text entry debug node","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":460,"y":240,"wires":[]},{"id":"b42b2908.665408","type":"debug","z":"67c3c9f9.a06c78","name":"Button click debug node","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":470,"y":400,"wires":[]},{"id":"fe2d6e02.ad949","type":"switch","z":"67c3c9f9.a06c78","name":"is text empty?","property":"textInput","propertyType":"flow","rules":[{"t":"empty"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":640,"y":280,"wires":[["db2479e4.104468"],["fa23a260.4e161"]]},{"id":"db2479e4.104468","type":"change","z":"67c3c9f9.a06c78","name":"enabled false","rules":[{"t":"set","p":"enabled","pt":"msg","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":810,"y":260,"wires":[["eb06ed9d.7f23f"]]},{"id":"fa23a260.4e161","type":"change","z":"67c3c9f9.a06c78","name":"enabled true","rules":[{"t":"set","p":"enabled","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":810,"y":300,"wires":[["eb06ed9d.7f23f"]]},{"id":"eb06ed9d.7f23f","type":"link out","z":"67c3c9f9.a06c78","name":"","links":["58d47e08.81ffc"],"x":935,"y":280,"wires":[]},{"id":"58d47e08.81ffc","type":"link in","z":"67c3c9f9.a06c78","name":"","links":["eb06ed9d.7f23f"],"x":195,"y":340,"wires":[["b573f57d.6290e8"]]},{"id":"93b54b1c.311778","type":"inject","z":"67c3c9f9.a06c78","name":"Init with empty string","topic":"","payload":"","payloadType":"str","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":160,"y":240,"wires":[["1330b995.eb0626"]]},{"id":"a0241251.a9cc4","type":"debug","z":"67c3c9f9.a06c78","name":"After function debug node","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":770,"y":400,"wires":[]},{"id":"1b214600.17935a","type":"ui_group","z":"","name":"Default","tab":"b8fb94f4.0d31d8","disp":true,"width":"12","collapse":false},{"id":"b8fb94f4.0d31d8","type":"ui_tab","z":"","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]

```

**In action...**  
 ![2019-08-15_10-23-16](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/7/7e3c281d67b577ed449d2667cb88b44e62f04114.gif)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [11 November 2021 23:30 UTC](https://discourse.nodered.org/t/how-to-work-with-text-input/14282/5 "2021-11-11T23:30:55Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
