In a formatted text field, I’m trying to allow a user to put in a whole number or a decimal number with one number after the decimal. It seems to not matter what RegEx pattern I use, it won’t allow me to type a decimal point. It limits the input to numbers, but just ignores the decimal (period) when I type it.
I’ve tried all different types of RegEx, this being the most recent: ^[1-9]\d*(.\d+)?$
A dot in regex means any char except line break. You have to escape it with
If you don’t already use it, I would definitely recommend www.regexr.com
It’s a fantastic tool for creating regex’s
In particular I use their cheat sheet all the time
Yes, I actually tried this (escaping .) and it works with regular regex in a python statement, but doesn’t seem to work in the regex field of a formatted text field.in Ignition.
Closest I got.
But it allows multiple periods.
A regex pattern of
\d+(\.\d)? seems to work pretty well; it won’t allow
123.45 but will allow
123.4. Technically you could start with a 0, so
0.1 would be accepted; not sure if that’s a deal breaker.
Did you try using this in a Formatted Text Field?? It still won’t let me type in a decimal (period). I have Allow Invalid Text set to False (which is required to follow the regex pattern).
Yeah, I tested in a formatted text field. The only setting I changed from default (besides the pattern) was to change the update mode to ‘Revert’ instead of ‘Commit or Revert’. I didn’t play around with it much, though, to be fair.