In this scenario, we need to verify that a user is older than a certain age (i.e. 18 or 21) based upon a date of birth entered in a Date/Time form field. This can be accomplished by creating a Submit Rule to validate the date field.
Follow these steps to build out this functionality:
- Add and configure a Date/Time control on the form:
- Enter a name like “Date of Birth”.
- Make sure the “Restrict past dates” toggle is set to No.
- You can also add a Description or Tooltip with a message like “You must be over 18 years old”.
- Configure a Submit Rule on the form:
- Go to the Rules tab.
- Click on the “Add submit rule” button in the Submit Rules section.
- Enter a descriptive Name for the rule like “Verify Date of Birth Over 18”.
- Configure the If statement.
- Click on the blue Insert button on the first drop-down field.
- Configure the Formula field.
- Find and insert the dateDiff() function from the Functions tab of the Lookup section.
- Enter “TotalYears” as the first parameter (make sure to include the quotation marks).
- Find and insert the “Date of Birth” form control as the second parameter.
- Find and insert the dateNow() function as the third parameter.
- The Formula should now be configured as (see the image below):
dateDiff(“TotalYears”,[Form].[Date of Birth],dateNow()) - Click the Insert button to save the Submit Rules.
- Select “Less than” from the second drop down field.
- Enter the age (18 or 21) that the user needs to be older than.
- Configure the Then statement.
- Select “Date of Birth” from the first drop-down field.
- Select “Show Validation Error” from the second drop-down field.
- Enter a message like “You must be older than 18 years old” in the third field.
- The Submit Rule should now look like the image below:
- Click the “Create rule” button to save and activate the Submit Rule.
- Test out your rule by going to the Preview tab, selecting a Date of Birth, and clicking the Submit button.
- If the user is under 18, the field will be marked as invalid and the validation message will appear.
- When the user is over 18, then the field is valid and the form can be submitted.
You can find out more about the Nintex Workflow Cloud functionality used in this blog:
Date/Time form control: https://help.nintex.com/en-US/nwc/Content/Designer/FormControls/DateTime.htm
Rules: https://help.nintex.com/en-US/nwc/Content/Designer/FormsRules.htm
Leave a Reply