Copy link to clipboard
Copied
Hi,
I've found a topic about validation of fields.
When a field meet a specific value, the background color changes.
var v = Number(event.value);
if (v>=1 && v<=6) {event.target.fillColor = color.red;}
else event.target.fillColor = color.white;
This is exactly what I want, but I'm using number field with decimals.
How can I check If the value is between 1 and 6.49 and color it red and with all other values, color it white ?
I've tried this, but it didn't work:
var v = Number(event.value);
if (v>=1 && v<=6.49) {event.target.fillColor = color.red;}
else event.target.fillColor = color.white;
Can anyone help me out here ?
Actually, because you formatted the fields as using a comma as the decimal separator, you do have to use it...
In addition, you need to disable the fields highlighting to be able to see the colors.
Go to Edit - Preferences - Forms and tick off "Show border hover color for fields".
Copy link to clipboard
Copied
Your code is correct and should work. What happens when you change the value of the field?
Keep in mind the script only executes when you exit the field, not the moment you enter the new value.
Copy link to clipboard
Copied
That's what I thought, but it doesn't work.
When I fill in a whole number (like 1 -6) the background changes to red.
If I fill in 6,4 or 5,2 or 2,2 etc. ect. the background changes to white.
Copy link to clipboard
Copied
Can you share the file with us (via Dropbox, Google Drive, Adobe Cloud, etc.)?
Copy link to clipboard
Copied
You have to use a period as the decimal separator, not a comma.
Copy link to clipboard
Copied
Sorry, that's what I did.
The field is formatted as Number, so I only enter a decimal in the field.
I've uploaded the PDF to Dropbox: Dropbox - Formulier1003.pdf
Please note that this document is in Dutch.
On page 3 I have used the conditional formatting in the 2 columns.
Copy link to clipboard
Copied
Actually, because you formatted the fields as using a comma as the decimal separator, you do have to use it...
In addition, you need to disable the fields highlighting to be able to see the colors.
Go to Edit - Preferences - Forms and tick off "Show border hover color for fields".
Copy link to clipboard
Copied
try67, your right.
It works fine now.
Thanks for your quick response !!