# typedInput and autoComplete

**URL:** https://discourse.nodered.org/t/typedinput-and-autocomplete/71699
**Category:** Developing Nodes
**Created:** [5 December 2022 08:14 UTC](https://discourse.nodered.org/t/typedinput-and-autocomplete/71699 "2022-12-05T08:14:04Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![ptweety](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ptweety/32/68053_2.png) [@ptweety](https://discourse.nodered.org/u/ptweety)
#### Post date: [5 December 2022 08:14 UTC](https://discourse.nodered.org/t/typedinput-and-autocomplete/71699/1 "2022-12-05T08:14:04Z")

</div>

Hi all,

I have some question regarding the autoComplete with a typedInput:

1. I wonder what is the correct way to attach autoComplete to a typedInput? Currently I have only found that `$(this).parent().find('.red-ui-typedInput-input')` might be the way to go.

2. When I want to disable autoComplete for a particular type of the typedInput I don't know how to do it. Can someone give a hint?

---

<div class="post-metadata">

### Author: ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)
#### Post date: [5 December 2022 09:55 UTC](https://discourse.nodered.org/t/typedinput-and-autocomplete/71699/2 "2022-12-05T09:55:57Z")

</div>

Hi @ptweety

You can set an `autoComplete` option on individual types.

For example, here you can see how we add autocomplete for the built in `msg` type:

> <https://github.com/node-red/node-red/blob/113d42ef35ccd55cb114c391fa3a55c7b8e94f18/packages/node_modules/%40node-red/editor-client/src/js/ui/common/typedInput.js#L169>

---

<div class="post-metadata">

### Author: ![ptweety](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ptweety/32/68053_2.png) [@ptweety](https://discourse.nodered.org/u/ptweety)
#### Post date: [5 December 2022 12:45 UTC](https://discourse.nodered.org/t/typedinput-and-autocomplete/71699/3 "2022-12-05T12:45:56Z")

</div>

Thank you, @knolleary

So I wrote something like this, which seems to work:

```auto
$(this).typedInput({
  types: [
    {
      value: 'str',
      label: 'string',
      icon: 'red/images/typedInput/az.svg',
      autoComplete: function () {
        return [
          { value: 'aa', label: 'AA' },
          { value: 'bb', label: 'BB' },
        ];
      },
    },
    { value: 're', label: 'regular expression', icon: 'red/images/typedInput/re.svg' },
  ],
});

```

Is there a better approach where I do not need to repeat `value`, `label`, `icon` of the default types?

---

<div class="post-metadata">

### Author: ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)
#### Post date: [5 December 2022 13:01 UTC](https://discourse.nodered.org/t/typedinput-and-autocomplete/71699/4 "2022-12-05T13:01:51Z")

</div>

> [@ptweety](#):
>
> Is there a better approach where I do not need to repeat `value`, `label`, `icon` of the default types

No - we hadn't considered providing a more convenient way to add custom autoCompletes to the existing 'str' option, rather than for an entirely custom type.

What you have is the right way to do it.

---

<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: [19 December 2022 13:02 UTC](https://discourse.nodered.org/t/typedinput-and-autocomplete/71699/5 "2022-12-19T13:02:07Z")

</div>

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