Skip to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Field contents Colour change if amount of data in field in incorrect

Featured Replies

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

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.

FYI this is even simpler in FM9 with conditional formatting.

  • Author

Thank you so much!

  • Author

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

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.

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 "?".

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.