0

I am trying to add a validation in Salesforce survey response. User should be able to enter numbers up to 2 decimal places.

Allowed inputs, 12 12.3 12.34

I am trying with ^\d+(.\d{1,2})?$ but I am getting error "The validation formulas specified in the following questions are invalid: Page 6 Question 1. Correct the formulas and try again."

I have tried same using validation rule and it gives syntax error there too.

2 Answers 2

0

The dot character in regular expression syntax matches all characters. You need to escape it if you want to math a literal dot. Corrected version:

^\\d+(\\.\\d{1,2})?$
1
  • Thanks for the response @Adrian. The expression doesn't throw any syntax error but it is not allowing the user to enter numbers or decimals. It is expecting \ in the input Nov 10, 2021 at 6:47
0

I have tried with pipe expression and it is working fine now. [0-9]+|[0-9]+[.][0-9]|[0-9]+[.][0-9][0-9]?

1
  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Dec 9, 2021 at 11:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.