Jump 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.

Featured Replies

I found a thread regarding this from 11 years ago, but couldn't find anything else so thought it may be best to check if the newer versions of FM have a solution to this problem. Is there any function or custom function that would allow me to check if the value in a field is numeric? I have a field that is supposed to be only numeric (primarily only positive integers) however occasionally there are entries like '1 + 4' or '10 + 2'. I'd like to enter the contents of this field into another field, but only with the entries that are numeric only. Any thoughts? Really appreciate any help.

Hi Eli

I know someone will have a better answer than this, but my thoughts would be 

1) Make the field type be 'number' and use the fields options validation set to 'Strict Data Type = Numeric'

2) If the field has to be a text field, but you want to check that it is numeric, the you could do something like :-
 

FieldIsNumber = If ( Filter ( numberField ; "0123456789" ) = numberField ; 1 ; 0 )

This Boolean result would be 1 if the field only contained numerals. It would give a positive result for '01234', but this may be OK.

Edited by rwoods

I'm assuming the field you refer to is defined as a text field. The test below is based on this.

A test for a TEXT field's contents being purely numeric is:

GetAsNumber ( Field) = Field

An example:  If a text field contains the value:  1+4

GetAsNumber (1+4) = 14 returns false, therefore the value '1+4' would be excluded for you.

On the other hand, GetAsNumber (18) = 18 returns true, therefore the value '18' would be accepted.

But if your field is defined as a number field, a more stringent test needs to be used such as:

GetAsNumber ( Field) = Field and Length(GetAsNumber ( Field)) = Length(Field)

Ralph

Edited by NLR

You might also try the Filter Funtion

Filter ( yourField ; "0123456789" )

  • Author

Thanks everyone for all the suggestions, these are all very helpful and have solved my problem. Really appreciate it!

On 7/10/2018 at 6:18 PM, rwoods said:

Hi Eli

I know someone will have a better answer than this, but my thoughts would be 

1) Make the field type be 'number' and use the fields options validation set to 'Strict Data Type = Numeric'

2) If the field has to be a text field, but you want to check that it is numeric, the you could do something like :-
 


FieldIsNumber = If ( Filter ( numberField ; "0123456789" ) = numberField ; 1 ; 0 )

This Boolean result would be 1 if the field only contained numerals. It would give a positive result for '01234', but this may be OK.

FieldIsNumber would return false for 1.0 (or 1,5 depending on your language) so make sure you include the dot and/or comma as well in the filter.

Good point @OlgerDiekstra

It certainly needs the decimal delimiter in the Filter list!

Create an account or sign in to comment

Important Information

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

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.