Validation to allow one decimal only

error-messagesvalidationvalidation-rule

I'm looking to validate percentage field type to ensure they contain only one decimal and can be between 0.0 and 100.0.I want to see an error message when more than one decimal is entered.

I tried this: NOT(REGEX(TEXT(ACC__c),"[0-9]{3}+(.[0-9]{1}?)?$"))

But not worked. Any tips would be appreciated.

Thanks

Best Answer

While creating the % field you can specify the number of decimal places. This is standard functionality. Decimal

Then you can have a simple validation

ACC__C < 0 || ACC__C > 1

To limit values between 0 to 100. Or you can have just this validation. That should also work. On UI, the number would be rounded off.

As noted by sfdcfox below, please check the rounding off for record created via API.