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.

Validate field 2 if field 1 is not empty

Featured Replies

Hello.

For example, I have two number fields: N1 and N2.

How can I validate the field N2 so that it cannot be left empty when the data was entered in N1 field?

In other words, if the user will enter smth in N1, he/she must enter smth in field N2 as well.

Many thanks.

FileMaker Version: 6

Platform: Windows 2000

Why not a lookup ?

Create a cTriggerKey that would match your serial or ID field.

Then set N2 to lookup its value from N1.

Don't forget to uncheck the box "if field is empty"

the cTrigger could look something like

Case(N1*GetField("N2"),(Status(CurrentTime)*0)+Serial,(Status(CurrentTime)*0)+Serial)

Then, whenever you try to enter N2 when N1 is empty, the value you entered will just be nulled. Else, N2 would lookup N1 value.

HTH

FileMaker Version: 6

Platform: Mac OS 9

Vasilek,

If you use a third field that is required to be validated by (N1=N2), it will give you a message if they aren't the same. I adjusted N2 so that it automatically fills in when N1 is originally filled-in. Otherwise, you never get the chance to get to N2 before the "not valid" message appears.

Hope this helps.

Paul smirk.gif

FileMaker Version: 6

Platform: Windows XP

Two Field Validation.zip

  • Author

Sorry, I didn't mean that 'smth' must be equal 'smth'. On the contrary, value in N1 is a price and value is N2 is minimum qty. So, when the user will enter the price in N1, he/she must enter a minimum qty of the product can be sold at this price in N2.

Well, this value wouldn't come here by magic.

So if it is stored in some place, I still believe a lookup (pretty easy one this time) is what you need to grab it.

Or you might enlight us a bit more... crazy.gif

Well, in any case, here's one way to make sure your user would enter some value in N2 if N1 is not empty.

Now, a script would just bypass any field validation, as well as imports.

FileMaker Version: 6

Platform: Mac OS 9

Field2Validation.fp5.zip

For the field validation for N2, validate by calculation:

If(not IsEmpty(N1), not IsEmpty(N2),1)

Uncheck "Validate only if field has been modified".

Or you could change it so N2 must be empty if N1 is empty:

If(IsEmpty(N1), IsEmpty(N2), not IsEmpty(N2))

You could also modify this to check to a range of numbers.

  • Author

Of course the value in N2 will not come by magic, the user must enter it.

FileMaker Version: 6

Platform: Windows 2000

Just a note for Ugo's enjoyment:

If(IsEmpty(N1), IsEmpty(N2), not IsEmpty(N2)) = IsEmpty(N1) xor not IsEmpty(N2). wink.gif

LOL

xor is coming up as mushrooms these days grin.gif

FileMaker Version: 6

Platform: Mac OS 9

So that's what xor is for...Always wondered.

Yep. It's a powerful logical operator that states either operand may be true, but not both. It's also known as the exclusive or (hence the x), as opposed to the inclusive OR (either or both operands may be true).

  • Newbies

I found this discussion because I was trying to do the same thing . . . guarantee that if one field is filled in, the second must also be filled in. I actually tried If(IsEmpty(N1), IsEmpty(N2), not IsEmpty(N2)) as the field validation for N2. The result is that the validation never kicks in.

Do I need to use the third field for the validation step?

Here's another wrinkle - maybe I'm going about this the wrong way: I would like N2 to be filled in by a script that opens another file.

The overall plan for my solution is that after the user enters info in one of two fields (N1 or N3) they must execute a script which creates a related record in the second file. They must use Script 1 if they filled in N1, and Script 3 if they filled in N3. My idea is that Script 1 is they only way they can fill in N2, which is not on the layout. Thus, if they don't execute the correct script they will not be permitted to exit the record if I make the validation strict. However, the validation does not occur. Am I missing something obvious?

It sounds like you want your field validation on N3 instead. Since N2 would only be filled in by a script, you should not have field validations for that field.

Or since you will be calling a script anyway to fill in N2, don't use field validations at all. Instead check your data entry when the script is launched--the script checks that only one field is filled in, then it branches to the correct sub-script.

  • Newbies

You're correct, I want validation on N3 - I got lost in the example there and misstated myself! Nevertheless, since the validation is being ignored, I'm trying to figure out how I can ensure that the field is checked to see if it's valid.

Did you uncheck "Validate only if field has been modified"?

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.