# How to set an limit to the value entered in text input node

**URL:** <https://discourse.nodered.org/t/how-to-set-an-limit-to-the-value-entered-in-text-input-node/67050>\
**Category:** General\
**Created:** [29 August 2022 03:05 UTC](https://discourse.nodered.org/t/how-to-set-an-limit-to-the-value-entered-in-text-input-node/67050 "2022-08-29T03:05:36Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ganesh](https://avatars.discourse-cdn.com/v4/letter/g/f19dbf/32.png) [@Ganesh](https://discourse.nodered.org/u/Ganesh)\
**Post date:** [29 August 2022 03:05 UTC](https://discourse.nodered.org/t/how-to-set-an-limit-to-the-value-entered-in-text-input-node/67050/1 "2022-08-29T03:05:36Z")

</div>

Hi  
I want to create an input box for my dashboard which has a limit of min = 0 and max = 100 value so only value within the limit can be entered  
I am using text input node but unable to set this min and max value  
Thanks

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [29 August 2022 06:52 UTC](https://discourse.nodered.org/t/how-to-set-an-limit-to-the-value-entered-in-text-input-node/67050/2 "2022-08-29T06:52:53Z")

</div>

Can you use the numeric input node instead? That allows a range to be specified.

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [29 August 2022 07:11 UTC](https://discourse.nodered.org/t/how-to-set-an-limit-to-the-value-entered-in-text-input-node/67050/3 "2022-08-29T07:11:17Z")

</div>

you could add a switch and change node to validate your input.  
e.g.

```auto
[{"id":"a085d44b.1361f","type":"ui_text_input","z":"9a86d59e88442f2c","name":"","label":"","tooltip":"","group":"2d4fe667.28f8ba","order":10,"width":0,"height":0,"passthru":false,"mode":"number","delay":"0","topic":"topic","sendOnBlur":true,"className":"","topicType":"msg","x":330,"y":300,"wires":[["6d6e18d7.8fc69"]]},{"id":"e716a705.8ae3","type":"change","z":"9a86d59e88442f2c","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$$.payload > 100 ? 100 : 0","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":380,"y":360,"wires":[["a085d44b.1361f"]]},{"id":"6d6e18d7.8fc69","type":"switch","z":"9a86d59e88442f2c","name":"","property":"payload","propertyType":"msg","rules":[{"t":"btwn","v":"0","vt":"num","v2":"100","v2t":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":520,"y":300,"wires":[["eb30ff93.865c28"],["e716a705.8ae3"]]},{"id":"eb30ff93.865c28","type":"debug","z":"9a86d59e88442f2c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":690,"y":280,"wires":[]},{"id":"2d4fe667.28f8ba","type":"ui_group","name":"demo","tab":"1caa8458.b17814","order":1,"disp":true,"width":"12","collapse":false},{"id":"1caa8458.b17814","type":"ui_tab","name":"Demo","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

```

---

<div class="post-metadata">

**Author:** ![Ganesh](https://avatars.discourse-cdn.com/v4/letter/g/f19dbf/32.png) [@Ganesh](https://discourse.nodered.org/u/Ganesh)\
**Post date:** [29 August 2022 09:27 UTC](https://discourse.nodered.org/t/how-to-set-an-limit-to-the-value-entered-in-text-input-node/67050/4 "2022-08-29T09:27:26Z")

</div>

How to make numeric node to only send value when pressed enter

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [29 August 2022 10:22 UTC](https://discourse.nodered.org/t/how-to-set-an-limit-to-the-value-entered-in-text-input-node/67050/5 "2022-08-29T10:22:45Z")

</div>

I don't think that is possible.

---

<div class="post-metadata">

**Author:** ![Ganesh](https://avatars.discourse-cdn.com/v4/letter/g/f19dbf/32.png) [@Ganesh](https://discourse.nodered.org/u/Ganesh)\
**Post date:** [30 August 2022 06:30 UTC](https://discourse.nodered.org/t/how-to-set-an-limit-to-the-value-entered-in-text-input-node/67050/6 "2022-08-30T06:30:16Z")

</div>

Hi  
Instead of it setting to high (100) or low(0) value when validation fails can we make it to show the previous validated value

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [30 August 2022 06:40 UTC](https://discourse.nodered.org/t/how-to-set-an-limit-to-the-value-entered-in-text-input-node/67050/7 "2022-08-30T06:40:47Z")

</div>

Yes, just store the validated value after the switch node, and recall it in the change node  
e.g.

```auto
[{"id":"46a3ef25.e51988","type":"ui_text_input","z":"30af2d3e.d94ea2","name":"","label":"","tooltip":"","group":"2d4fe667.28f8ba","order":10,"width":0,"height":0,"passthru":false,"mode":"number","delay":"0","topic":"topic","sendOnBlur":true,"className":"","topicType":"msg","x":230,"y":280,"wires":[["b8ba37a5.b83c6"]]},{"id":"508058d5.00d08","type":"change","z":"30af2d3e.d94ea2","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"previous","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":280,"y":340,"wires":[["46a3ef25.e51988"]]},{"id":"b8ba37a5.b83c6","type":"switch","z":"30af2d3e.d94ea2","name":"","property":"payload","propertyType":"msg","rules":[{"t":"btwn","v":"0","vt":"num","v2":"100","v2t":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":420,"y":280,"wires":[["65f03d12.e0b5ec"],["508058d5.00d08"]]},{"id":"65f03d12.e0b5ec","type":"change","z":"30af2d3e.d94ea2","name":"","rules":[{"t":"set","p":"previous","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":600,"y":260,"wires":[["dc534367.9d975"]]},{"id":"dc534367.9d975","type":"debug","z":"30af2d3e.d94ea2","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":810,"y":260,"wires":[]},{"id":"2d4fe667.28f8ba","type":"ui_group","name":"demo","tab":"1caa8458.b17814","order":1,"disp":true,"width":"12","collapse":false},{"id":"1caa8458.b17814","type":"ui_tab","name":"Demo","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

```

---

<div class="post-metadata">

**Author:** ![Ganesh](https://avatars.discourse-cdn.com/v4/letter/g/f19dbf/32.png) [@Ganesh](https://discourse.nodered.org/u/Ganesh)\
**Post date:** [30 August 2022 06:58 UTC](https://discourse.nodered.org/t/how-to-set-an-limit-to-the-value-entered-in-text-input-node/67050/8 "2022-08-30T06:58:53Z")

</div>

Thanks For The Help !

---

<div class="post-metadata">

**Author:** ![Ganesh](https://avatars.discourse-cdn.com/v4/letter/g/f19dbf/32.png) [@Ganesh](https://discourse.nodered.org/u/Ganesh)\
**Post date:** [30 August 2022 12:46 UTC](https://discourse.nodered.org/t/how-to-set-an-limit-to-the-value-entered-in-text-input-node/67050/9 "2022-08-30T12:46:51Z")

</div>

Hi  
One Last Thing When I am disabling the text input node the the value in the text box is changing How can I keep the Same Value before disabling it

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [30 August 2022 13:17 UTC](https://discourse.nodered.org/t/how-to-set-an-limit-to-the-value-entered-in-text-input-node/67050/10 "2022-08-30T13:17:02Z")

</div>

I don't see that. What is it changing from/to?

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [30 August 2022 13:29 UTC](https://discourse.nodered.org/t/how-to-set-an-limit-to-the-value-entered-in-text-input-node/67050/11 "2022-08-30T13:29:00Z")

</div>

I would suspect that when you disable you are also feeding in a msg.payload, hard to say without seeing your flow.

---

<div class="post-metadata">

**Author:** ![Ganesh](https://avatars.discourse-cdn.com/v4/letter/g/f19dbf/32.png) [@Ganesh](https://discourse.nodered.org/u/Ganesh)\
**Post date:** [2 September 2022 09:50 UTC](https://discourse.nodered.org/t/how-to-set-an-limit-to-the-value-entered-in-text-input-node/67050/12 "2022-09-02T09:50:10Z")

</div>

HI  
When i have payload value is equal to 0 I have to disable the input node when it is equal to 1 enable it

```auto
[
    {
        "id": "3938c99931cd8d33",
        "type": "ui_text_input",
        "z": "0b2bb18eaac24be5",
        "name": "",
        "label": "",
        "tooltip": "",
        "group": "78fdd8ca6d0e5ae8",
        "order": 2,
        "width": "2",
        "height": "3",
        "passthru": true,
        "mode": "number",
        "delay": "0",
        "topic": "topic",
        "sendOnBlur": false,
        "className": "",
        "topicType": "msg",
        "x": 610,
        "y": 980,
        "wires": [
            [
                "4187c5b465f8e158"
            ]
        ]
    },
    {
        "id": "7e15aca24d6f1348",
        "type": "function",
        "z": "0b2bb18eaac24be5",
        "name": "function 25",
        "func": "msg.enabled = false;\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 450,
        "y": 960,
        "wires": [
            [
                "3938c99931cd8d33"
            ]
        ]
    },
    {
        "id": "22fb1ce473ee0dc7",
        "type": "function",
        "z": "0b2bb18eaac24be5",
        "name": "function 26",
        "func": "msg.enabled = true;\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 450,
        "y": 1000,
        "wires": [
            [
                "3938c99931cd8d33"
            ]
        ]
    },
    {
        "id": "71be8eed9ff6e8bf",
        "type": "switch",
        "z": "0b2bb18eaac24be5",
        "name": "",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "0",
                "vt": "num"
            },
            {
                "t": "eq",
                "v": "1",
                "vt": "num"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 310,
        "y": 980,
        "wires": [
            [
                "7e15aca24d6f1348"
            ],
            [
                "22fb1ce473ee0dc7"
            ]
        ]
    },
    {
        "id": "8f920d217b07bd1a",
        "type": "inject",
        "z": "0b2bb18eaac24be5",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "0",
        "payloadType": "num",
        "x": 150,
        "y": 960,
        "wires": [
            [
                "71be8eed9ff6e8bf"
            ]
        ]
    },
    {
        "id": "2aa71e6d7ac3601d",
        "type": "inject",
        "z": "0b2bb18eaac24be5",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "1",
        "payloadType": "num",
        "x": 150,
        "y": 1000,
        "wires": [
            [
                "71be8eed9ff6e8bf"
            ]
        ]
    },
    {
        "id": "4187c5b465f8e158",
        "type": "debug",
        "z": "0b2bb18eaac24be5",
        "name": "debug 58",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 760,
        "y": 980,
        "wires": []
    },
    {
        "id": "78fdd8ca6d0e5ae8",
        "type": "ui_group",
        "z": "0b2bb18eaac24be5",
        "name": "Set Point ",
        "tab": "4d6c02f95a8f26c8",
        "order": 11,
        "disp": true,
        "width": "23",
        "collapse": false,
        "className": "sp"
    },
    {
        "id": "4d6c02f95a8f26c8",
        "type": "ui_tab",
        "name": "LCC Control",
        "icon": "fa-gear",
        "order": 7,
        "disabled": false,
        "hidden": false
    }
]

```

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [2 September 2022 10:12 UTC](https://discourse.nodered.org/t/how-to-set-an-limit-to-the-value-entered-in-text-input-node/67050/13 "2022-09-02T10:12:35Z")

</div>

When you disable it, what value does it change to, and what is in msg.payload in the message that disables it?

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [2 September 2022 10:13 UTC](https://discourse.nodered.org/t/how-to-set-an-limit-to-the-value-entered-in-text-input-node/67050/14 "2022-09-02T10:13:37Z")

</div>

As suspected you are feeding a msg.payload in with msg.enabled, delete msg.payload, also uncheck `if msg arrives pass on input, through to output`

```auto
[{"id":"8f920d217b07bd1a","type":"inject","z":"30af2d3e.d94ea2","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"0","payloadType":"num","x":70,"y":3520,"wires":[["7e15aca24d6f1348"]]},{"id":"7e15aca24d6f1348","type":"function","z":"30af2d3e.d94ea2","name":"function 25","func":"msg.enabled = msg.payload === 1 ? true : false;\ndelete msg.payload\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":300,"y":3540,"wires":[["3938c99931cd8d33"]]},{"id":"2aa71e6d7ac3601d","type":"inject","z":"30af2d3e.d94ea2","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1","payloadType":"num","x":70,"y":3560,"wires":[["7e15aca24d6f1348"]]},{"id":"3938c99931cd8d33","type":"ui_text_input","z":"30af2d3e.d94ea2","name":"","label":"","tooltip":"","group":"78fdd8ca6d0e5ae8","order":2,"width":"2","height":"3","passthru":false,"mode":"number","delay":"0","topic":"topic","sendOnBlur":false,"className":"","topicType":"msg","x":530,"y":3540,"wires":[["4187c5b465f8e158"]]},{"id":"4187c5b465f8e158","type":"debug","z":"30af2d3e.d94ea2","name":"debug 58","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":710,"y":3480,"wires":[]},{"id":"78fdd8ca6d0e5ae8","type":"ui_group","z":"30af2d3e.d94ea2","name":"Set Point ","tab":"4d6c02f95a8f26c8","order":11,"disp":true,"width":"23","collapse":false,"className":"sp"},{"id":"4d6c02f95a8f26c8","type":"ui_tab","name":"LCC Control","icon":"fa-gear","order":7,"disabled":false,"hidden":false}]

```

---

<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:** [16 September 2022 10:14 UTC](https://discourse.nodered.org/t/how-to-set-an-limit-to-the-value-entered-in-text-input-node/67050/15 "2022-09-16T10:14:09Z")

</div>

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