Need to make sure text or numbers are entered in components

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.


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

1 Like

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-

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

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.
1 Like

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

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

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

  • 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.


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:

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

3 Likes

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:

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.

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

... 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.

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

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.

1 Like