Creating Conditonally Required Fields in InfoPath

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):

  1. Select the field that should be conditionally required. In the Rules pane, select New > Validation. Name the rule.

  2. 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)

  3. Click the Add button to add a second condition:

    (field that should be optionally required) (is blank)

  4. Click OK. Here is what the completed rule should look like:

  5. In the ScreenTip field enter “Required

  6. 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.

    What the fields look like on load:

    What the fields look like on load:

    Selecting the field that sets the other field to be required:

    Selecting the field that sets the other field to be required:

    After data has been entered into the field and focus has left field:

    After data has been entered into the field and focus has left field:

59 thoughts on “Creating Conditonally Required Fields in InfoPath

  1. any idea how you would do this with a ‘people picker’ field … because that doesn’t allow you to add a validation rule ?

  2. just to follow up on jeff… any idea how you would do this with a ‘people picker’ field … because that doesn’t allow you to add a validation rule ?.. i also need a solution for this 🙂

  3. I have exact same requriement in all my infopath forms. I tried exactly same way but it didnt work for me.This is urgent.
    Please help!

  4. Thanks for this terrific article. It did the trick for one of two conditional fields.

    I noticed that on multiChoice Fields, the validation rule option does not appear. How would you do it if you had a conditional on a multichoice field? I tried to add an extra statement in the first rule saying (if dropdown one is blank OR multi…is blank,) and that didn’t work.

  5. This is just a thought .. The people picker does not allow any validation to be filled in .. however what we can do is create a temp text field… create an action rule on this which says “If people group picker is not empty Set temp_field to value “1” ” … Now this temp field can be used as the entry by which you can set your field validation condition .. i.e. put the condition in the validation of field A as “if temp_field is equal to “1” ”

    Hope this will help someone !! Do tell us all if this works !

  6. Pingback: How to create conditionally required fields in InfoPath | Jack Tingzon's Blog

  7. I have a request from a department for a form to have all question in a column answered before a signature could be added to the form for that section. The form contains 2 columns A and B and each column has a list of question which answer is driven from a drop down depending on the state of the project. I am not sure how to make this happen. Is this possible as a no code solution?

    Example of the form below.

    Question’s Column A(50% complete) Column B(100%Complete)
    Q1 Drop down Drop down
    Q2 Drop down Drop down
    Q3 Drop down Drop down
    Sig from column A
    Sig from Column B

    I am new to InfoPath but I just feel like I am asking google the wrong question. I am guessing this is a validation rule of some sort. If I am wrong and someone could point me in the right direction it would be a lot of help. The signature portion will have a digital signature as well. Not sure if that matters or not.
    Any help would be greatly appreicated.

  8. This works perfectly. However, on my form the user can tab through the required field even though there is a red asterik and complete the remainder of the form. Is there a rule that prevents a user from completing the rest of the form if the required field remains blank?

  9. I found out that you can create this for multiselectable fields also. After you create the Rule, go back and edit it. On the field select “Select a field or group…” Click on your Field (your value you had in the original rule should show up in the Select drop down on the bottom. Change your condition to “contains”. This worked fine in IP2010

    • One thing you will need to change on the instructions above.
      In the dialog for “Select Field or Group” click – “Show advanced view”
      Highlight the Value of the field you are validating against.
      Change the Select drop down to “Any occurence of Value”
      Hope this helps…

  10. Thanks! I had to tweek a little since I was using a drop down list (Status) as the condition for the Test field, and it could be 1 of 3 options selected… had to make 3 separate rules for each option with the Status = Options and Text = blank, otherwise if I put it all together with ORs it didn’t work. But you pointed me in the right direction. Thank you!!

  11. Great post, thanks. I encountered the exact same frustration regarding the ‘blank’ field. Nice when someone takes the time to fully doucment it.

  12. For people picker, have used an additional field (not displayed) to store the account id (AccountId from people picker). then displayed a banner based on the content of the new field. Then added validation rules (not sure about screen tip) to the new non displayed field. The validation comes when submitting through even though the new field is not displayed.

  13. THANK YOU!!!!!! I spent an hour trying to figure this out before I searched the net for the assist. Lesson learned on my part, view other people’s lessons learned first!

  14. thanks for this explanation!!
    Apparently in the condition, if you want to compare to a value from a lookup field, you have to use the ID of the list item in stead of the value or title.

  15. What worked for me was deleting the field off of the sharepoint list and info path form. Create a new field within info path save and publish it so it updates to the sharepoint list. So the reverse of the normal process but with nonrequired field properties and no errors.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s