Set pattern-matching conditions for data by using conditional formatting

In Microsoft Office InfoPath, you can use conditional formatting to specify different formatting options for a control that is based on conditions that occur on the form. If the specified conditions are true when a user fills out a form that is based on your form template, the conditional formatting is applied.

This article explains how to use conditional formatting to help ensure that the data that a user enters into a specific control matches a predetermined pattern. For example, you can add conditional formatting to a text box control for a phone number to require that the user enters a three-digit area code.

Note: To require that data matches a predetermined pattern, you can also use data validation.

In this article

Before you begin

Compatibility considerations

Set pattern-matching conditions for a control

Before you begin

In order to complete this procedure, your form template must contain a control that supports conditional formatting. Although you can set a pattern-matching condition for any InfoPath control that supports conditional formatting, pattern matching works best with controls that display characters such as numbers, letters, or punctuation. For example, setting a pattern-matching condition for a text box is useful, but setting such a condition for a check box will not yield useful results.

Top of Page

Compatibility considerations

When you design a form template in InfoPath, you can choose a specific compatibility mode to design a browser-compatible form template. When a browser-compatible form template is published to a server running InfoPath Forms Services, and then browser-enabled, forms based on the form template can be viewed in a Web browser. When you design a browser-compatible form template, some controls are unavailable in the Controls task pane because they cannot be displayed in a Web browser.

List of controls that support conditional formatting

The following table lists the Office InfoPath 2007 controls that support conditional formatting and whether they are available for browser-compatible form templates.

Note: Although you can set a pattern-matching condition for any InfoPath control that supports conditional formatting, pattern matching works best with controls that display characters such as numbers, letters, or punctuation. For example, setting a pattern-matching conditional for a text box is useful, but setting such a condition for a check box will not yield useful results.

Controls that support conditional formatting

Available for browser-compatible form templates?

Check box

Yes

Date picker

Yes

Drop-down list box

Yes

Expression box

Yes

List box

Yes

Option button

Yes

Optional section

Yes

Repeating section

Yes

Repeating table

Yes

Rich text box

Yes

Section

Yes

Text box

Yes

File attachment

Yes

Button

Yes

Bulleted, numbered, or plain list

No

Choice section

No

Combo box

No

Horizontal repeating table

No

Ink picture

No

Master/Detail

No

Multiple-selection list box

No

Picture

No

Repeating recursive section

No

Vertical label

No

Top of Page

Set pattern-matching conditions for a control

  1. On the form template, click the control that you want to set a pattern-matching condition for.

  2. On the Format menu, click Conditional Formatting.

  3. In the Conditional Formatting dialog box, click Add.

  4. Under If this condition is true, in the first box, click Select a field or group.

  5. In the Select a Field or Group dialog box, click the field that corresponds to the control, and then click OK.

  6. In the second box in the Conditional Format dialog box, select matches pattern or does not match pattern.

  7. In the third box, click Select a pattern.

  8. Under Standard patterns in the Data Entry Pattern dialog box, click the pattern that you want, and then click OK.

    List of standard patterns

    Pattern

    Example

    Phone number

    (555) 555-0100

    Social Security number

    123-45-6789

    Zip code

    98052

    Zip code + 4

    98052-6399

    Note: To create a custom pattern, click Custom pattern, type the pattern that you want in the Custom pattern box, and then click OK.

  9. Under Then apply this formatting, select the formatting that you want.

  10. Click OK twice to save the condition and return to the form template.

  11. To test your changes, click Preview on the Standard toolbar, or press CTRL+SHIFT+B.

Top of Page

Share Facebook Facebook Twitter Twitter Email Email

Was this information helpful?

Great! Any other feedback?

How can we improve it?

Thank you for your feedback!

×