0

Does anybody have any experience with Salesforce custom validations in Surveys? I am trying to get a validation to work for a short text question that will accept either a whole number or a 2 digit decimal number. I can get it to accept 2 digit decimal with this: [0-9]+[.][0-9][0-9]

But that will not allow it to accept a number without a decimal point. Every other formula I have tried always gives an error. I have noticed that the different REGEX examples in Saleforce's survey documentation don't work as shown. For example, their example of an email validation:

REGEX({!Email_Address},“[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,4}“) 

gives an error, although I was able to figure that one out. But I can't get it to accept a formula to validate a whole number or a number with 2 decimal spots.

2
  • 1
    these regex questions can also be addressed on stackoverflow
    – cropredy
    Commented Apr 12, 2021 at 19:23
  • Please note that this question is not specifically about regex. It is a question about regex formulas not working with Salesforce surveys. Validations that would normally work for normal fields will not work for me in the surveys.
    – Mark V
    Commented Apr 13, 2021 at 20:27

1 Answer 1

0

You can use | for OR so for your example: [0-9]|[0-9]+[.][0-9][0-9]

There are enhancements you could make, for instance: [0-9]*|[0-9]*.[0-9]{1,2}. This would allow a postive integer or a positive decimal up to 2 decimal places.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .