How to require a field based on Age

How to require a field based on Age

Some communities require fields based on age.  Examples include...
  1. Only require a picture for members over 12 (children don't need pictures).
  2. Only require Proof or Residency for adults over 21.     

How To 

How to hide the image field for children.
In this example, we're going to hide the picture (patronImage) if the age is less than 12.  

GO TO: FORM TAB
After the Member Birthdate field, find the field....  
  1. Field Name: patronImage
  2. Field Label: Member Image
  3. Required for Patron: Checked
  4. Modifiable after Submit: Checked
  5. Initially Hidden: Unchecked
  6. Hide/Unhide Calculation, use: (dateStr(sibling("patronBirthDate")) != "") && (age(sibling("patronBirthDate")) < 12)
Edit the age (12) as needed.


How to require proof of residency for adults.
In this example, we're going to unhide a mandatory DOCUMENT FIELD if the member is 21 years old or older.    

GO TO: FORM TAB
After the patronBirthDate field, add the field....  
  1. Field Name: UploadPOR
  2. Instructions: Members 21 years old and older must upload proof of residency.  (Tip: Upload a copy of a phone bill.)
  3. Field Label: Proof of Residency
  4. Required for Patron: Checked
  5. Modifiable after Submit: Checked
  6. Initially Hidden: Checked
  7. Hide/Unhide Calculation, use: age(sibling("patronBirthDate")) >= 21
Edit the age (21) and instructions as needed.



How to require proof of residence for adults ONLY if there are more than 2 adults.
In this example, we're going to unhide a mandatory DOCUMENT FIELD if the member is 21 years old or older.    BUT only if the application has more than 2 members over 21.  

GO TO: CONSTANTS TAB

Step 1
Create a constant that determine the age proof or residency is required.  
  1. Constant Name: AGE_ADULT
  2. Value (enter the fee): 21
  3. Description: Enter the age of an adult.  Used to determine when proof or residency is required.  


GO TO: CALCULATIONS TAB

Step 2
Add a calculation that counts the number of adults.
  1. Result Name: AdultCount
  2. Expression: countIfCmp("patronAge", #AGE_ADULT, ">=")


GO TO: FORM TAB

Step 3
Use a hidden INLINECALCULATION FIELD field to calculate each member's age.   
Add or confirm the following field is within the patronsgroup.  Place it directly under the field patronBirthDate.
  1. Field Name: patronAge
  2. Field Label: Age: 
  3. Initially Hidden: Checked
  4. Calculation Result Name: age(sibling("patronBirthDate"))
  5. Decimal Places: 0
Step 4
After the patronAge field, add the field....  
  1. Field Name: UploadPOR
  2. Instructions: Members 21 years old and older must upload proof of residency.  (Tip: Upload a copy of a phone bill.)
  3. Field Label: Proof of Residency
  4. Required for Patron: Checked
  5. Modifiable after Submit: Checked
  6. Initially Hidden: Checked
  7. Hide/Unhide Calculation, use: age(sibling("patronBirthDate")) >= #AGE_ADULT && {AdultCount}>2
Edit the age (21) and instructions as needed.
GO TO: PREVIEW TAB

Step 5
Preview & Test your application using the preview tab.