Sign in with Microsoft
Sign in or create an account.
Select a different account.
You have multiple accounts
Choose the account you want to sign in with.

Adding validation rules to controls in a form template ensures that the data collected is accurate and consistent. When you add a text control, users can type anything into it. However, if you want to restrict users to entering an email address, then use a validation rule that ensures that what a user enters into the field matches the pattern of an email address, and prompt them to correct it if it is not.

In this article

Validation rule examples

The following are some examples of how to use validation rules in a form template:

  • To let users know when the amount they enter for an expense item exceeds the approved amount.

  • To ensure users enter a properly formatted phone number into a phone number box.

  • To make sure a billing address is entered when a user does not select a check box that indicates that their billing address is the same as their shipping address.

Note:  Data validation rules prevent a user from submitting a form if any errors exist.

Ways to notify users about a validation error

Validation rules are designed to check for certain conditions within a form and, if those conditions are met, notify the users so that they can take corrective action. There are two ways that validation rules notify users about a validation error — ScreenTips and dialog boxes. A ScreenTip is always be associated with a validation error and appears when the user moves the mouse cursor over a control with a validation rule associated with it. You can also specify an additional dialog box message to be displayed when users enter invalid data.

By default, dialog boxes only appear when a user right-clicks a control with a validation error and then clicks Full error description in InfoPath Filler or clicks on the link in the validation ScreenTip in a Web browser. You can also configure the rule to display the dialog box automatically. This option only applies when filling out forms in InfoPath Filler when the user makes an invalid entry, and then tries to exit the control. Even when this option is selected, dialog box messages are not shown automatically when filling out forms in a Web browser.

Add a validation rule

Use the Add Rule button

Included, pre-defined validation rules can be added by using the Add Rule button. Do the following to quickly add a validation rule:

  1. Select a control.

  2. On the Home tab, in the Rules group, click Add Rule.

  1. Click the type of condition that the rule needs to meet in order to apply, such as Is Not an E-mail Address if you want the rule to make sure that the contents of the field are formatted like an email address.

  2. Click Show Validation Error.

Note:  Depending on the type of condition chosen, you might be asked to enter additional information.

  1. When finished, the Rules task pane appears and you can make any necessary changes to the rule.

Use the Rules task pane

Complete the following steps to add a validation rule from the Rules task pane:

  1. Create a validation rule.

    1. Click a control.

    2. If the Rules task pane is not visible then, on the Home tab, in the Rules group, click Manage Rules.

    3. Click New.

    4. Click Validation.

    5. In the Details for box, enter a name for the rule.

  2. Specify the conditions.

    1. Click None in the condition section.

    2. If the condition for your rule is based on a field, complete the following:

      1. Click field that the rule is based on.

      2. Click the operator, such as is equal to.

      3. Enter the value.

        Note:  It is also possible to base a rule on an expression or a set of signable data. For more information about these advanced scenarios, see the corresponding section under Advanced condition scenarios.

    3. Click And to add another condition and repeat step 2 or click OK.

      Note:  After adding a second condition, the And button is replaced with a box. Leave and selected if both the first and each subsequent condition needs to be true for the data validation to be applied. Otherwise, if only one of the conditions should be true for the data validation to be applied, select or.

  3. Specify a message.

    1. Enter the text in the ScreenTip box.

    2. If you want to add a more detailed message or enable an automatic dialog box message, do the following:

      1. Click Show more options.

      2. Click Show ScreenTip and dialog box message to enable the automatic dialog box message.

        Note:  Only ScreenTips are displayed when filling out forms in a Web browser.

      3. In the Dialog box message box, enter the text.

This displays the Data Entry Pattern dialog box from which you can select from several pre-defined, standard patterns. If none of these patterns meets your needs, you can indicate a custom pattern. Custom patterns can require the use of special characters, which can be easily inserted by selecting them from the Insert special character box.

Advanced condition scenarios

The following are advanced scenarios that you can use when setting the condition of a data validation rule.

  • Base a rule on an expression

An expression is a set of values, fields or groups, functions, and operators. Use an expression to check the value of a field, such as verifying a date that a user enters or the cost of an item entered into an expense report.

  1. Click The expression.

  2. Enter the expression.

Note:  For more information, see Add functions and formulas.

  • Base a rule on a set of signable data

By basing a rule on a set of signable data, you can add an error message to a submit button if a user has not signed the form, thus helping to ensure that the form is signed before submitting. This condition is only supported in InfoPath Filler forms.

  1. Click Select set of signable data.

  2. In the Select Set of Signable Data dialog box, select the set of signable data, and then click OK.

  3. Click the desired condition, and then click the criteria.

Note:  For more information, see Digital Signatures in InfoPath 2010.

  • Base a rule on a user’s role

You might have one form for all users but, depending on their role, require different information from each group of users. As a result, you can use a data validation error to display a validation error if a user that has been assigned to a particular role forgets to fill in a required field. User roles are only supported in InfoPath Filler forms.

  1. Click User’s current role from the first box.

  2. Click the operator, such as is equal to.

  3. Click the role or click Manage roles to manage user roles.

Top of Page

Need more help?

Want more options?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.

Was this information helpful?

What affected your experience?
By pressing submit, your feedback will be used to improve Microsoft products and services. Your IT admin will be able to collect this data. Privacy Statement.

Thank you for your feedback!