Hello,
I've browsed the tool mastery sessions on the Error Message tool, but was unable to find what I need.
I am building an app with multiple questions - some are drop-downs, some are free form text.
For the free form text tools, I have a field that must begin with the letter "i". I want an error message to appear when the user has omitted the i.
I also need to restrict one of the entry tools so the user receives an error message if they enter anything other than numeric values.
I've been unable to find the right expressions to use within the error message tool. For the first one, I tried Startswith([#1], !"i") - but the message is that I tried to apply a string operator to a numeric value. I'm sure there is a better way to do this. Looking forward to your assistance!
Thank you,
Molly
Solved! Go to Solution.
Hi @MCDR929
For the first one you'll want something like:
Left([#1],1) != "i"
Which takes the first character on the left and tests whether it is not equal to "i".
For the numeric characters, you can use a regex expression to test to make sure there are only numerics:
REGEX_Match([#1], '[^0-9]')
This should work - it will return true if there are any characters that are not 0-9.
Let me know if this works for you.
Luke
Hi @LukeM ,
The first one worked, but not the REGEX expression. This isn't something I've used at all before. Is there anything additional I need to do before using REGEX expressions?
Thank you,
Molly
So sorry @MCDR929 that was my laziness.
What you actually need to use is:
REGEX_CountMatches([#1], '[^0-9]') > 0
This is going to count how many occurrences of non-numeric characters there are and error if there are more than 0.
RegEx is a way of describing characters, letters, numbers etc in certain patterns. If you're interested, https://regexone.com/ is a very good learning resource.
Luke
@LukeM - This is great! I'll be sure to check out the Regex resource you provided. I appreciate it.
Thanks,
Molly