Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×
The Claris Museum: The Vault of FileMaker Antiquities at Claris Engage 2025! ×

This topic is 6096 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

Hi

I have a field containing a set of numbers (eg telephone number).

Let’s say I want the field to contain eleven digits.

If the incorrect amount of digits is entered I would like all the digits in the field to change colour say from black to red to alert the data entry person that there are too few or too many digits.

While I realise I could use field validation to ensure that the correct number of digits are entered I would like to learn a calculation to satisfy the colour option.

Can any one help with the calculation (or script) please?

Thanks

Posted

You can use a field with an Auto-enter calculated value.

Case ( Length ( PhoneNum ) ≠ 11; TextColor ( PhoneNum ; RGB (255 ; 0 ; 0 ) ); Evaluate ( PhoneNum ) )

Make sure that you have 'Do not replace existing value' Unchecked.

Posted

FYI this is even simpler in FM9 with conditional formatting.

Posted

Before I posed the question I did try with my own calculations which were unsuccessful.

I tried with “If” and then with “case” but I never though of the last bit of your calculation “Evaluate”

Could you explain please what the “Evaluate” bit does?

thanks

Posted

Well since you are applying a text style change to the current value in the field, it will keep that style change unless you remove it.

So if you have typed in something that isnt 11 characters, it will apply the style of text color red. If you left it like such:

Case ( Length ( PhoneNum ) ≠ 11; TextColor ( PhoneNum ; RGB (255 ; 0 ; 0 ) ); PhoneNum )

Then although it is 11 characters, it will still be red since the field already has that style applied. The Evaluate in this instance basically allows you to return only the true data in it. You could also have used TextFormatRemove or TextColorRemove.

Posted

You cannot use Evaluate() alone just to remove the styling. You must protect the entry from being actually evaluated as an expression, by using the Quote() function:

Evaluate ( Quote ( PhoneNum ) )

Otherwise, an entry of "123-456-7890" will return "-8223" (subtract 456 from 123, and 7890 from the result) and "(123) 456-7890" will return "?".

Posted

Ah yes, slight oversight... lol.

This topic is 6096 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.