f you’ve used the InfoPath Contact Selector before, you might have seen that it does not support validation like other InfoPath controls do. There is no option on the Properties dialog for the control to make it a required field. To work around this, I used a combination of rules and conditional formatting to prevent the form from being submitted if the control does not have a value.

The easiest way to do this is to create conditional rules in the Submit Options dialog:

  1. Configure your form and add a Contact Selector control
  2. Go to Tools > Submit Options.
  3. Make sure that Allow Users to Submit this Form is checked.
  4. Click the option to Perform custom action using rules.
  5. Click the Rules… button.
  6. In the Rules dialog, click the Add… button.
  7. In the Rule dialog, click the Set Condition… button.
  8. In the Condition dialog, pull down the first dropdown, choose Select a field or group…, and drill down and choose the DisplayName field from your data connection. Select is blank in the second dropdown.
  9. Click the And> button to add a second condition.
  10. In the last dropdown on the first condition, change it from And to Or.
  11. In the second condition, select the DisplayName field again, and choose is not present for the condition. Your two conditions should look like this:
  12. Click OK. In the Rule dialog, do not add any Actions. Check the box to Stop processing rules when this rule finishes
  13. Make sure that this rule appears first in the list of Rules.The only downside to this approach is that there is no visual to the user, since InfoPath Forms Services does not support showing a dialog message. The form will just not do anything. To get an even better user experience, You can hide the Submit option from the Toolbar, and use your own Submit buttons with Conditional Formatting:
  14. Drag a button on the page.
  15. Right-click and choose Conditional Formatting….
  16. Click Add… to add conditions.
  17. In the Condition dialog, add the two conditions in steps 8-11 above, and choose Disable this Control.
    Now, your submit button will be disabled until the user picks a person.
Show Buttons
Hide Buttons

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.