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
Diego MorenoDiego Moreno 

validation rule for currency field with 2 decimal values


i am trying to make a validation rule for a currency field with 2 decimal values so that it only enables the user to put .00 .25 .50 and .75, with any other value in the decimals i need it to trigger the erro message.
this is what i've got so far:

NOT(REGEX(TEXT( Gross_Pay__c ), "[0-9]+[.]{1}[25,50]{2}")) it works for 25 and other values but not for 50 
Shashikant SharmaShashikant Sharma
First you could achieve it directly with field attributes setting :  Length to 2 and Decimal Places to 2
Shashikant SharmaShashikant Sharma
Let me knwo if you are still having issues with it ot any reason why you can not use it from database level field property.
Diego MorenoDiego Moreno
i understand, but i need it to be a validation rule since the only values that are ment to be allowed in the decimal place are .00 .25 .50 .75 those are the only 4 possible options. the field has to show an error message for any other decimal value .01 .02 .34... .99
David BermanDavid Berman
How about MOD(Your_currency_field, .25) > 0
This would divide your field by 0.25.  For values including .00, .25, .50, .75 there should be no remainder.
Zac  OteroZac Otero
This was the formula that worked for me!
NOT(REGEX(TEXT(Your_currency_field__c ), "(?!0\\d)\\d+(?:[.](?:25|5|75|0)0*)?(?!\\d)"))

Hope that this helps!
Hello Everyone,

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

Here i wrote a validation rule :

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