# Need to make sure text or numbers are entered in components

**URL:** <https://forum.inductiveautomation.com/t/need-to-make-sure-text-or-numbers-are-entered-in-components/79441>\
**Category:** General Discussion\
**Tags:** perspective\
**Created:** [September 21, 2023, 9:24am UTC](https://forum.inductiveautomation.com/t/need-to-make-sure-text-or-numbers-are-entered-in-components/79441 "2023-09-21T09:24:10Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Purushothaman\_R](https://avatars.discourse-cdn.com/v4/letter/p/8797f3/32.png) [@Purushothaman\_R](https://forum.inductiveautomation.com/u/Purushothaman_R)\
**Post date:** [September 21, 2023, 9:24am UTC](https://forum.inductiveautomation.com/t/need-to-make-sure-text-or-numbers-are-entered-in-components/79441/1 "2023-09-21T09:24:10Z")

</div>

Hi guys, i have text field and numeric entry field component in a view. So my requirement is like user should provide inputs(type numbers or text) if not user should not be able to submit the form. It is moreover like a google form if we leave blank text field the outer layer of the component will be red right. How can i make sure user provided all the necessary details.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/f/df6f9577a77568a5ace0353fcb66552bbd0ad863.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/6/36cc0ab27eec5485f00a6b1e67f8d4f26d76a11f.png)

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [September 21, 2023, 9:28am UTC](https://forum.inductiveautomation.com/t/need-to-make-sure-text-or-numbers-are-entered-in-components/79441/2 "2023-09-21T09:28:02Z")

</div>

Double-posted and answered already. Please don't do that.

> [@Format Text Field](https://forum.inductiveautomation.com/t/format-text-field/44347/17):
>
> Response to new question above moved to [https://forum.inductiveautomation.com/t/need-to-make-sure-text-or-numbers-are-entered-in-components/79441/5](https://forum.inductiveautomation.com/t/need-to-make-sure-text-or-numbers-are-entered-in-components/79441/5)

---

<div class="post-metadata">

**Author:** ![Purushothaman\_R](https://avatars.discourse-cdn.com/v4/letter/p/8797f3/32.png) [@Purushothaman\_R](https://forum.inductiveautomation.com/u/Purushothaman_R)\
**Post date:** [September 21, 2023, 9:36am UTC](https://forum.inductiveautomation.com/t/need-to-make-sure-text-or-numbers-are-entered-in-components/79441/3 "2023-09-21T09:36:12Z")

</div>

sorry i am new to ignition and ignition forum community i won't double post hereafter can you kindly elaborate like you said how to disable confirm order until values are entered-

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [September 21, 2023, 9:39am UTC](https://forum.inductiveautomation.com/t/need-to-make-sure-text-or-numbers-are-entered-in-components/79441/4 "2023-09-21T09:39:26Z")

</div>

OK. Let's delete our posts in the other thread and deal with your topic here.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [September 21, 2023, 9:40am UTC](https://forum.inductiveautomation.com/t/need-to-make-sure-text-or-numbers-are-entered-in-components/79441/5 "2023-09-21T09:40:02Z")

</div>

> so my requirement is if a user try to type alphanumeric values or numbers ...

Numbers are alphanumeric.

> ... I need a togglepopup to be opened stating "Only strings are allowed" so that user can know only strings are allowed.

Everything you can type is a string so that prompt wouldn't help anyone.

Anyway, don't do that. Use standard web interface so that your application works as the users expect. For example,

- Set the border of each text field to red and change to black when the field has correct data type in it.
- Use a tooltip to explain the input requirements.
- Disable Confirm Order until all the fields pass the data validation criteria.

---

<div class="post-metadata">

**Author:** ![Purushothaman\_R](https://avatars.discourse-cdn.com/v4/letter/p/8797f3/32.png) [@Purushothaman\_R](https://forum.inductiveautomation.com/u/Purushothaman_R)\
**Post date:** [September 21, 2023, 9:50am UTC](https://forum.inductiveautomation.com/t/need-to-make-sure-text-or-numbers-are-entered-in-components/79441/6 "2023-09-21T09:50:55Z")

</div>

Thank you, Can you kindly elaborate like i am new to ignition i don't know how to change border of text field from red to black after meeting its requirements

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [September 21, 2023, 10:05am UTC](https://forum.inductiveautomation.com/t/need-to-make-sure-text-or-numbers-are-entered-in-components/79441/7 "2023-09-21T10:05:29Z")

</div>

Sorry, no further help until you delete your other post.

---

<div class="post-metadata">

**Author:** ![Purushothaman\_R](https://avatars.discourse-cdn.com/v4/letter/p/8797f3/32.png) [@Purushothaman\_R](https://forum.inductiveautomation.com/u/Purushothaman_R)\
**Post date:** [September 21, 2023, 10:16am UTC](https://forum.inductiveautomation.com/t/need-to-make-sure-text-or-numbers-are-entered-in-components/79441/9 "2023-09-21T10:16:15Z")

</div>

To be honest i don't know how to delete the post now i have deleted the post can you elaborate it now

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [September 21, 2023, 11:17am UTC](https://forum.inductiveautomation.com/t/need-to-make-sure-text-or-numbers-are-entered-in-components/79441/10 "2023-09-21T11:17:37Z")

</div>

- Set `props.deferUpdates : false`. This will allow the validation to recalculate on each change of text.
- On each text field create a custom property, `valid : false`.
- Create a binding on the custom property. In the example below I'm just checking that exactly nine characters have been entered.

 ![Validation binding](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/3/a3f49f3fcfcb4ad72cd9c075ed18550af74ba200.png)  
If you want to match certain patterns then you are going to have to study regular expressions (regex) and it's probably not something you're going to figure out today.

Repeat for each text field.

Then add a binding on the Confirm Order button enabled property. It will look something like this:

 ![Button enabled binding](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/5/35482c8c0a6500c64694819f84abf1dcdca94588.png)

Ignition's built-in expression language has some functions that will allow you to do basic checks such as string length checks or checking for numbers or dates.

[https://docs.inductiveautomation.com/display/DOC81/Expression+Functions](https://docs.inductiveautomation.com/display/DOC81/Expression+Functions)

---

<div class="post-metadata">

**Author:** ![Felipe\_CRM](https://avatars.discourse-cdn.com/v4/letter/f/dfb087/32.png) [@Felipe\_CRM](https://forum.inductiveautomation.com/u/Felipe_CRM)\
**Post date:** [September 21, 2023, 3:30pm UTC](https://forum.inductiveautomation.com/t/need-to-make-sure-text-or-numbers-are-entered-in-components/79441/11 "2023-09-21T15:30:45Z")

</div>

I'm not sure there's any built-ins for checking if a string contains only numeric characters or only alphabetic characters. You could use `toInt()` or `toFloat()` with the fallback option to do it, like in this post:

> [@\[BUG\] 8.1.0rc3 Numeric expression on string returns 0 instead of failover](https://forum.inductiveautomation.com/t/bug-8-1-0rc3-numeric-expression-on-string-returns-0-instead-of-failover/40170):
>
> I’m trying to use toInt({value}, -999999) to check if the value is a string or a number, however the expression returns “0” even if the value is a string like “off”. Is there any other way that I can check this?

but I think this is one case where a script transform would be worth it.

Python has some nice built-ins like `isalpha()` (a-z only), `isalnum()` (a-z + digits allowed but no special characters), and `isnumeric()` (only digits allowed). For anything more complicated you'd have to do regex like Transistor said.

Please correct me if I'm missing anything.

---

<div class="post-metadata">

**Author:** ![Purushothaman\_R](https://avatars.discourse-cdn.com/v4/letter/p/8797f3/32.png) [@Purushothaman\_R](https://forum.inductiveautomation.com/u/Purushothaman_R)\
**Post date:** [September 25, 2023, 4:20am UTC](https://forum.inductiveautomation.com/t/need-to-make-sure-text-or-numbers-are-entered-in-components/79441/12 "2023-09-25T04:20:17Z")

</div>

Thank you Transistor that worked. But my supervisor is asking me to do using IF condition now, like if length of the text field is greater than 0 the confirm button should be enabled until it meets the requirement and the script needs to be written in button component no custom property or others way need to be done only script need to be written for checking length of text field component. Can anyone kindly help me with this

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [September 25, 2023, 6:17am UTC](https://forum.inductiveautomation.com/t/need-to-make-sure-text-or-numbers-are-entered-in-components/79441/13 "2023-09-25T06:17:38Z")

</div>

> ... that worked. But my supervisor is asking me to do using IF condition now, ...

Why? What problem is he trying to avoid?

> ... like if length of the text field is greater than 0 the confirm button should be enabled until it meets the requirement and the script needs to be written in button component ...

The script button can't detect events in the text fields. The checks have to be done on the text components.

> ... no custom property or others way need to be done only script need to be written for checking length of text field component.

The expression bindings I have shown are the correct way to do this and most efficient and, therefore, fastest way to do this.

You need to ask your supervisor to explain what problem he sees with this approach and why he is recommending something else. It may be that he has experience with some other HMI package that didn't offer the features of Ignition.

---

<div class="post-metadata">

**Author:** ![Purushothaman\_R](https://avatars.discourse-cdn.com/v4/letter/p/8797f3/32.png) [@Purushothaman\_R](https://forum.inductiveautomation.com/u/Purushothaman_R)\
**Post date:** [September 25, 2023, 7:25am UTC](https://forum.inductiveautomation.com/t/need-to-make-sure-text-or-numbers-are-entered-in-components/79441/14 "2023-09-25T07:25:24Z")

</div>

> [@Transistor](#):
>
> You need to ask your supervisor to explain what problem he sees with this approach and why he is recommending something else. It may be that he has experience with some other HMI package that didn't offer the features of Ignition.

Okay transistor Thanks for the response i will speak with my supervisor 😇

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [September 25, 2023, 12:54pm UTC](https://forum.inductiveautomation.com/t/need-to-make-sure-text-or-numbers-are-entered-in-components/79441/15 "2023-09-25T12:54:15Z")

</div>

> [@Purushothaman\_R](#):
>
> script needs to be written in button component no custom property or others way need to be done only script

That's the exact opposite way one should be using ignition ! And I'm speaking as someone who is MUCH more comfortable with code than with ignition's features.
