# Text node doesn't show empty spaces (if generated by a function)

**URL:** https://discourse.nodered.org/t/text-node-doesnt-show-empty-spaces-if-generated-by-a-function/51262
**Category:** Dashboard
**Created:** [19 September 2021 22:08 UTC](https://discourse.nodered.org/t/text-node-doesnt-show-empty-spaces-if-generated-by-a-function/51262 "2021-09-19T22:08:15Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![GiovanniG](https://avatars.discourse-cdn.com/v4/letter/g/ecd19e/32.png) [@GiovanniG](https://discourse.nodered.org/u/GiovanniG)
#### Post date: [19 September 2021 22:08 UTC](https://discourse.nodered.org/t/text-node-doesnt-show-empty-spaces-if-generated-by-a-function/51262/1 "2021-09-19T22:08:15Z")

</div>

Hi, that's strange, if I inject a string with spaces they are correctly displayed, if I use a function it doesn't show the space, please consider this flow:

```auto
[{"id":"d906ef38.9de2c","type":"ui_text","z":"cc2c1666.3d904","group":"cad2b1e9.412298","order":2,"width":0,"height":0,"name":"time","label":"","format":"{{msg.payload}}","layout":"row-center","x":1310,"y":1720,"wires":[]},{"id":"c1e98346.64745","type":"inject","z":"cc2c1666.3d904","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"1","crontab":"","once":true,"onceDelay":"2","topic":"","payload":"","payloadType":"date","x":790,"y":1720,"wires":[["fbc6f385.caca38"]]},{"id":"fbc6f385.caca38","type":"simpletime","z":"cc2c1666.3d904","name":"Clock","mydate":true,"myymd":false,"myyear":false,"mymonth":false,"mymonthn":false,"mydom":false,"mydoy":false,"myday":false,"myhourpm":false,"myhour":true,"mytime":false,"mytimes":false,"myminute":true,"myminutes":false,"mysecond":true,"mymillis":false,"myepoch":false,"myrawdate":false,"mypm":false,"x":970,"y":1720,"wires":[["c37b259d.90424"]]},{"id":"c37b259d.90424","type":"function","z":"cc2c1666.3d904","name":"","func":"if (msg.mysecond%2==1) {duepunti=\":\";} else {duepunti=\" \";}\nmsg1={payload:msg.mydate};\nmsg2={payload:msg.myhour+\" \"+duepunti+\" \"+msg.myminute};\nreturn [msg1,msg2];","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1150,"y":1720,"wires":[["a5b8ae14.0e046"],["d906ef38.9de2c"]]},{"id":"a5b8ae14.0e046","type":"ui_text","z":"cc2c1666.3d904","group":"cad2b1e9.412298","order":1,"width":0,"height":0,"name":"date","label":"","format":"{{msg.payload}}","layout":"row-center","x":1310,"y":1680,"wires":[]},{"id":"cad2b1e9.412298","type":"ui_group","name":"6Colonna","tab":"ef482f31.2d1628","order":6,"disp":false,"width":"6","collapse":false},{"id":"ef482f31.2d1628","type":"ui_tab","name":"Franco","icon":"dashboard","disabled":false,"hidden":true}]

```

---

<div class="post-metadata">

### Author: ![Gunner](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gunner/32/43582_2.png) [@Gunner](https://discourse.nodered.org/u/Gunner)
#### Post date: [20 September 2021 02:02 UTC](https://discourse.nodered.org/t/text-node-doesnt-show-empty-spaces-if-generated-by-a-function/51262/2 "2021-09-20T02:02:06Z")

</div>

> [@GiovanniG](#):
>
> please consider this flow:

Please consider properly formatting all flows in a topic 🙂  
Use the **\</\>** icon in the topic editor screen

**EDIT** - Thanks zen, for the formatting edit on OP behalf

---

<div class="post-metadata">

### Author: ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)
#### Post date: [20 September 2021 06:53 UTC](https://discourse.nodered.org/t/text-node-doesnt-show-empty-spaces-if-generated-by-a-function/51262/3 "2021-09-20T06:53:08Z")

</div>

@GiovanniG with HTML (which is what get generated for the dashboard), the browser automatically reduces multiple spaces to one space (see: [4 Easy Ways to Insert Spaces in HTML](https://blog.hubspot.com/website/html-space)) so you need to insert a non-breaking space character. Try this, change your `function` node to this

```auto
if (msg.mysecond%2==1) {duepunti=":";} else {duepunti="&nbsp;";}
msg1={payload:msg.mydate};
msg2={payload:msg.myhour+"&nbsp;"+duepunti+"&nbsp;"+msg.myminute};
return [msg1,msg2];

```

and see if that does it for you.

---

<div class="post-metadata">

### Author: ![GiovanniG](https://avatars.discourse-cdn.com/v4/letter/g/ecd19e/32.png) [@GiovanniG](https://discourse.nodered.org/u/GiovanniG)
#### Post date: [25 September 2021 17:16 UTC](https://discourse.nodered.org/t/text-node-doesnt-show-empty-spaces-if-generated-by-a-function/51262/4 "2021-09-25T17:16:50Z")

</div>

thanks a lot!

---

<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: [9 October 2021 17:17 UTC](https://discourse.nodered.org/t/text-node-doesnt-show-empty-spaces-if-generated-by-a-function/51262/5 "2021-10-09T17:17:05Z")

</div>

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