Thursday, 14 March 2013

Conditional Validation Rules - InfoPath 2010

Using validation rules in InfoPath 2010 we can easily make certain fields become required based on a condition we set within the rule.

The example below requires the 'Employment end date' field only to become required if the user selects 'Fixed term' in the 'Employment type' field.

Basic form with some fields added

As we want to make the 'Employment end date' conditionally required, we need to select that field and click on the 'Manage Rules' icon in the Home ribbon.

Now that the 'Rules' menu is open, click new and select a 'Validation' rule.

Give the rule a name and then click on 'None' under the Condition heading.

In this example our condition is 'If Employment type is equal to Fixed term' then we want the field to be required.

Type 'Required' into the ScreenTip box and this is what will appear as a tip on the form when the field becomes required.

If you published the form and then opened a new item you would find that the field is now conditionally required. However you will not be able to submit using this rule as it is! see below.

'Employment end date' is not required on load.

With 'Employment type' changed to 'Fixed term' the field is now marked as required.

But if you try adding data to the newly required field, you will get a red dashed line and then a validation error should you try to submit the form. The error will be along the lines of "InfoPath cannot submit the form because it contains errors. Errors are marked with either a red asterisk (required fields) or a red, dashed border (invalid values).

There is an easy fix for this, by tweaking our validation rule condition we can avoid this validation error.

Go back to our field validation rule and modify the condition.

We need to tweak our condition to only make the field required if it is also blank.

Publish your form and you will have conditionally required fields with no validation errors!


  1. Matt you helped me a lot! Thank you for this blog, I don't understand why I must complete the "is blank" rule but I'll just follow the instructions. :)

  2. Hi Matt. I need to make a Person /Group and Choice (Multi-Select) field required based on the value of another field. Your example above looks PERFECT, but Validation is grayed out for the Person / Group field and the Choice (Multi-Select). Any ideas how to apply Validation to those types of fields?

  3. Looks like you need the "is blank" extension because Infopath doesn't work right. I mean, c'mon, I have the rule set the field to required, enter some data and THEN Infopath tells me the field can't be blank?
    Just another bug ...

  4. have no idea how long I have tried to figure out how to avoid the date error. Many thanks for this.

  5. Unfortunately validation rules are only available to use on some of the field types, and the person and group picker field is not one of them.

    There are workarounds (not perfect), one being to put the person field inside a section and hiding it until it becomes required.

    Take a look at this link

  6. Thank you so much! I never knew about the "is blank" requirement to remove the validation errors. Easy peasy

  7. Wow, many many thanks! I've been battling this error all morning, would have never though of adding that condition. Makes no sense but it does work :)

  8. Thank you Matt for this posting. I was at my wits trying to figure this out. Even thought I don't understand the need for the 2nd conditional check ("is blank") but it does fix the problem. Leave it to Microsoft to code something like this.

  9. Thank you very much, Matt! You've saved my life!!

  10. Never mind, i just made the last comment about not being able to get this to work, and USER ERROR! It worked!!

  11. Thank you for your clear instructions! Very helpful!

  12. Thanks mate. That was super cool and helpful... Cheers

  13. Matt-Matt... thanks so much. No really, THANKS! Hope you have a great day... mine just got better! (BA)

  14. Great help Matt! Thank you for sharing!

  15. Thanks for this helpful information I agree with all points you have given to us. I will follow all of them.
    SharePoint 2013 Online Training