Require a specific data entry pattern in a control
You can create data entry patterns that define how users must enter numbers and text into a control. For example, you can require that users enter a phone number with parentheses around the first three digits. Data entry patterns display error alerts when users type an incorrect pattern into a control.
Note Patterns do not automatically format data entry into a particular pattern.
- In design mode, select the control for which you want the validation to occur, and then click Data Validation on the Format menu.
- In the Data Validation dialog box, click Add.
- Make sure the first box under If this condition is true contains the control's field.
- In the second box, click does not match pattern.
- In the third box, click Select a pattern.
- In the Data Entry Pattern dialog box, do one of the following:
- In the Standard patterns box, select one of the patterns.
- In the Custom pattern box, enter a pattern. You can type directly in the box. To insert special characters in the pattern, click the character in the Insert special character box.Insert symbols specifying constraints on the pattern, such as letters only, digits only, characters only, hyphens, periods, commas, and parentheses. In addition, you can use the following symbols to allow multiple occurrences of a given character:
Zero or one (?) The preceding character must occur either zero or one time. For example, \d? means a digit (\d) must occur zero times or one time.
Zero or more (*) The preceding character can occur zero or more times. For example, r* means r can occur zero or more times.
One or more (+) The preceding character must occur one or more times. For example, .+ means a character (.) must occur one or more times.
- Click OK.
- In the Error alert type box, click the type of error alert you want to display to users.
- In the ScreenTip box, type the text you want to display when a user points to the control or right-clicks the control.
- In the Message box, type the text you want to display in the dialog box either immediately (if you chose a dialog box alert) or when the user requests more details (if you chose an inline alert).
Note The information in this topic may not apply if you are working with a form designed using Microsoft Office InfoPath 2003 without the service pack installed. Learn more