Program: InfoPath 2010 (2007 form template)
I spent the best part of two days trying to figure out the following; hopefully it will prevent someone else from wasting a bunch of time trying to figure out the same thing.
So I have a form in InfoPath where I want to make some fields required only if another field is selected first. I created a validation rule that appeared to do what I wanted until I tried to submit the form. The conditionally required fields were outlined in red even though they contained data and the form refused to submit. After digging around a bunch of InfoPath dev forums, I kept seeing the same reference to “add a rule making the field blank”. Here are the steps to creating a conditionally required field in InfoPath (I am using InfoPath 2010 so the exact directions may need to be tweaked for 2007 users):
- Select the field that should be conditionally required. In the Rules pane, select New > Validation. Name the rule.
- Under Condition, click on the None link. You will be adding two conditions. The first condition is:
(field that determines whether or not the other field is required) (is equal to) (True)
This assumes the first field is a checkbox. If you have radio buttons with a specific choice, like Yes and No, make sure the radio selectors have values:
(field that determines whether or not the other field is required) (is equal to) (Yes)
- Click the Add button to add a second condition:
(field that should be optionally required) (is blank)
- Click OK. Here is what the completed rule should look like:
- In the ScreenTip field enter “Required“
- To test your form, click the Preview Form button in the ribbon. The conditionally required field should display as not required until the field that makes the field required is selected. The field should now display a red asterisk indicating it is required. Once data has been entered and the focus removed from the field, the form should show no validation errors.