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.

Conditionally required fields

Featured Replies

Is there a way to make a field conditionally required? For example, can you make field A required to be "not empty" only if field B has a value, but not required to be not empty if field B does not have a value?

In the validation options, you can validate by calculation. It uses a Boolean expression (True/False).

  • Author

Forgive my ignorance, but how does this actually work? I have a group of address fields, (street, city, state, etc.) that I want to be required if the value of the field "Different contact Info?" equals "Yes" If the value of that field is "No" (or any other value), I want the address fields to not be required. I tried checking the "validate by calculation" and then creating a calculation where "Different Contact Info? = "Yes" but that didn't make the field required to have a value even if "Different Contact Info" = "Yes"

Try this calc into validation option of field address:

Case(

Different contact Info? = "YES" and IsEmpty ( Self ) ; 0;

1

)

Remember to uncheck the box: Validate only if field has been modified

Try this (using "address" field for example):

Case( Different Contact Info = "Yes" ; not IsEmpty( address ) ; 1 )

  • Author

I tried that, but still no luck. The only thing that changes whether the field is required or not is if the "Not Empty" checkbox is toggled, regardless of whether "Validated by Calculation" is checked or not.

Try again.

Different contact Info? may have 3 status:

1) Empty

2) some chars

3) YES

but only when in status 3) we want Address NOT empty

So the expression:

Different contact Info? = "YES" and IsEmpty ( Self )

must produce an error.

Any other must be accepted.

  • Author

There's a saying, "trying the same thing over and over and expecting different results amounts to insanity." So I would have to change something in order to make it worth trying. Any suggestions? It would help if I were a bit clearer on what the "Validate by calculation" really means. What I want it to mean is, "this field cannot be empty if this other field has a value of 'yes'." Is there a programmatic way of achieving this end?

"this field cannot be empty if this other field has a value of 'yes'."

[color:red]IF

IsEmpty ( Self ) and Different contact Info? = "YES"

[color:red]ERROR

"Is there a programmatic way of achieving this end?"

Yes.

BTW: my calc can even be simpler:

not ( IsEmpty ( Self ) and Different contact Info? = "YES" )

that is the same as saying:

I don't want [color:red]( not ) this field empty [color:red]( IsEmpty ( Self ) ) when [color:red]( and ) Different contact Info? contains [color:red]( = ) "Yes"

Obviously trying the same thing isn't going to work...

You need to change something...it works fine for me. At the bottom of the calculation screen it tells you what represents True/False. "Non-zero results are true, Zero and empty results are false". If the result of the calculation is true, it accepts the value. Otherwise, it rejects the value and throws an error.

If your calculation isn't resulting in the correct value, it is something in the calc.

  • Author

Perfect, Danielle! Aside from giving me a workable solution, your example explained exactly how I could get this to work.

I really appreciate your help.

-e

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.