# Textfield Auto focus

**URL:** <https://forum.inductiveautomation.com/t/textfield-auto-focus/117622>\
**Category:** Ignition\
**Tags:** perspective, scripting, ignition81\
**Created:** [October 27, 2026, 1:59pm UTC](https://forum.inductiveautomation.com/t/textfield-auto-focus/117622 "2026-10-27T13:59:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sanjanakrishnamurthy](https://avatars.discourse-cdn.com/v4/letter/s/bcef8e/32.png) [@sanjanakrishnamurthy](https://forum.inductiveautomation.com/u/sanjanakrishnamurthy)\
**Post date:** [October 27, 2026, 1:59pm UTC](https://forum.inductiveautomation.com/t/textfield-auto-focus/117622/1 "2026-10-27T13:59:50Z")

</div>

Hi,

I'm trying to auto-focus a text field after a tag (bool) change...

To monitor the change, I have a parameter on-screen where the change happens. The textfield is used for barcode scanning and once the barcode is scanned, we wait for a tag to change to True.

I've written an onChange script for when the tag is true to save some data in a table and then to refresh the textfield back to empty. But we're having a hard time trying to focus the textfield after its reset to empty...

Currently we're using - {path to textfield component}.focus() at the end of the change script. The rest of the change script is working as expected, except the focus part. Not sure where we're going wrong with this one... Any help would be highly appreciated...

Thanks!

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [October 27, 2026, 2:10pm UTC](https://forum.inductiveautomation.com/t/textfield-auto-focus/117622/2 "2026-10-27T14:10:45Z")

</div>

Since you are using perspective, I would use the `barcodescannerinput` component. You can set it up to look for a certain regex pattern, or starting and stopping characters for framing. This way, you don't have to worry about focusing a text field.

---

<div class="post-metadata">

**Author:** ![Ryan\_Deardorff](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan_deardorff/32/63815_2.png) [@Ryan\_Deardorff](https://forum.inductiveautomation.com/u/Ryan_Deardorff)\
**Post date:** [October 27, 2026, 2:22pm UTC](https://forum.inductiveautomation.com/t/textfield-auto-focus/117622/3 "2026-10-27T14:22:59Z")

</div>

`.focus()` only works when the component is inside a container that already has focus, so you might try focusing its parent container(s) first. You can steal focus from a parent or sibling, but not a cousin.
