function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Raj88Raj88 

Validation rule for currency with 2 decimal values

Valid: 12.00, 12.10, 12.01, 12.56
Not Valid: 12, 12.1, 12.0

NOT(REGEX(TEXT(Price__c), "[0-9]+[.][0-9][0-9]?"))

I am writing an validation rule for currency field. Can anyone help me with this.
Anil KamisettyAnil Kamisetty
There are so many way you can have this validation rule in place. Here is one of them.

Logic : Get the Decimal point and then convert it to Text. Check the length.

Len(Text(Price__c- (ROUND(Price__c ,0))))<2

Note : If the decimal points are 0 or 1, the above condition becomes true and the validation error is thrown.

Note : If this answers your question, please mark this as an Answer. Thus others can get help too.
Anil KamisettyAnil Kamisetty
The result will be 0.1 or 0. Accordingly you need to check the length ( less than 2 or 3, based on your requirement). This should help you get started for sure.
Raj88Raj88
So if the field value is like this "56.00" can we give validation for this?
Chandra PrakashChandra Prakash
Hi vivekh881,
Please try this code :

NOT(REGEX(Price__c,"[0-9]+[.]{1}[0-9]{2}"))

Thanks
----------
Chandra Prakash Sharma
Bisp Solutions Inc.
AgiAgi
hi,
you can use this one too:
NOT(REGEX(Right(Currency_text__c,3), "[.]{1}[0-9]{2}"))
AgiAgi
so
NOT(REGEX(Right(Price__c,3), "[.]{1}[0-9]{2}"))    :)
Raj88Raj88
Hi agi,

Error: Incorrect parameter type for function 'Right()'. Expected Text, received Number

This is the error i am gettting.
AgiAgi
Hi,
use this
NOT(REGEX(Right(TEXT(Price__c),3), "[.]{1}[0-9]{2}"))
and put Decimal places : 2

and put User-added image
Raj88Raj88
The issue i am facing is 12.00 is not accepted. Its showing error. I need 12.00 to be accepted and 12 should not be accepted.
Chandra PrakashChandra Prakash
Hi,
   Vivekh

you should try this formula
if it helpful
NOT(REGEX(Price__c,"[0-9]+[.]{1}[0-9]{2}"))
its accepted 12.00,12.10,12.20 etc. value and it not accepted 12.1,12 etc value..


Regards,
Chandra Prakash Sharma
Bisp Solutions Inc.
http://bispsolutions.com

llisallisa
Hello Everyone,

i am trying to make a validation rule for a text field with 2 decimal values just like 20/30,40/50,1/2,12/4 and single numbers.
It should give error message if it is like 122/22 or 299/349.

Here i wrote a validation rule :
NOT(REGEX(Edited_Discount__c,"[0-9]+[/]{1}[0-9]{2}"))

It will Validate 20/30,40/50 but when i give single it throws validation exception.
Please help me on this .

Thanks
Lisa