Curious the best way to go about this. I want to restrict a text input to a specific length, must be 6 characters (no more, no less), and each position is restricted to certain characters. For example, the first position can only have C,E,F,G,V. The 2nd-6th will have similar restrictions. I’m assuming I will use the key press event? Anyone have any additional tips or help?
I ran into one issue I was hoping someone could help on. I was able to get the formatted text field to work with reg ex pattern. But, I still want to verify the operator has entered something. I can’t use committedValue because it always seems to have a value, if not from what they entered, then from the last time. I would rather use text, but for some reason it’s not exposed. So, how can one verify a value was entered?
I think that you would need to that check their last input was a carriage return, the following may get you started, since most of this can be done with Python ( no colon equals no emoji ) https://docs.python.org/2/howto/unicode.html#unicode-literals-in-python-source-code
I would otherwise suggest looking at the support policy section, then sending a message to support- yet this issue may or may not be considered their job- so here is the link ( no colon equals no emoji ) https://support.inductiveautomation.com
P.S. Carriage return would be hexadecimal 0D
Best regards
I did call support, we weren’t able to get it to work but, it was very simple to create the functionality using python:
import re
if event.propertyName == 'text':
pattern = '^(?i)(c|e|f|g|v)(5|7|2|9|n|p)(0|c|x|s|g)(a|3|4|7|9|j|k|b|m|n|c|l|h|g|r|f|s|o|t|u|d|v|q|x|f|p)(0|1|2|3|g|b|c|d|j|k|l|m|n|r|4|t|f|5|6|7|8)(0|1|3|4|5|6|7|a|b|c|d|f|h|j|k|p|q|r|t|s|u|v|w|y|z)'
string = event.source.text
result = re.match(pattern, string)
if result and len(string) == 6:
event.source.regExOK = True
else:
event.source.regExOK = False
The only thing I would recommend is to put your group elements in alphanumeric order (0-9, a-z) like you did in the last group to make it easier to manage down the road, and avoid repeated elements.