Format Text Field

Hi Guys, I am new to Ignition and currently I faced some problems. Hope I can get your helps.

It is possible to format the text field which only allows the users to insert numeric instead of alphabetical characters. Currently I’m using the perspective modules so it is possible to do that ?

Thanks in advance

You should use the Numeric Entry Field instead of the Text Field.
Screen Shot 2021-03-10 at 10.40.32PM

Hi Bro cmallonee,

I cant use the Numeric Entry Field because what I want is let the user to insert their contact number so Numeric Entry Field is not the option for me. You get it what I means ? Therefore, what should I do in order to format the text field that only accept numbers. For instance, 01589652586.

Thanks in advance.

You already asked the same question in another topic…

There’s no way to prevent a user from entering characters in a Text Field. You can prevent string characters from being placed into the value with smart logic in a value change script, but again, that won’t prevent a user from putting characters into the Text Field. So using this route you’ll encounter a difference between what is displayed and what the true value is until focus is lost, at which point the component will display the true value.

User is able to supply invalid characters, but the change script is writing the last “valid” value to props.text whenever an invalid character is supplied:

After focus is lost:

I don’t understand why the Numeric Entry Field can’t be used for a contact number… If you modify the props.format property to be 00000000000, then you can have your contact number displayed in it:


The value is not exact, so I guess I could see where that might be your problem, but you just need to account for that in whatever write action you have by prepending 0 the the value as necessary.

Problem Solved. Thanks ALL.

How did you solve it?

It looks like this did the trick for OP:

They “just did” :wink:

Hi Bro cmallonee, I actually used the normal Python code to solve the problem.

phone_number.isdigit() == False or len(phone_number) > 12:

This is my sample code.

But how did you apply that to the Text Field? As part of a change script?

Hi Bro cmallonee, I actually apply it at the button event configuration.

What kind of event?