Require a specific type of data
- In design mode, double-click the control whose data type you want to change.
- On the Data tab in the Control Properties dialog box, click the data type you want in the
Data type
box.
Note If a user types a value with the wrong data type, a standard inline alert will appear.
Note If your form is based on a sample form or a pre-existing XML Schema, you may not be able to change the data type.
Require a specific value or range of values
- 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.
- In the If this condition is true boxes, enter the condition.
- To add additional conditions, click
And, and then, in the rightmost box under
If this condition is true,
do one of the following:
- To show the error alert only when both conditions are true, click and.
- To show the error alert when one or both conditions are true, click or.
- 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).
Require a specific pattern, such as a phone number
- 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.
- 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).
To create an event handler in InfoPath, you must associate the event with the correct field, and then write the code in Microsoft Script Editor (MSE) or Microsoft Visual Studio .NET 2003. Because the event handler is referred to in the form definition (.xsf) file, you should not create a new handler entirely from within MSE or Visual Studio. In addition, you should not modify the event handler name or its arguments.
- 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
Events list in the
Data Validation dialog box, click the
event you want to create or modify, and then click
Edit.
Note This opens MSE or Visual Studio and positions the cursor at the specified event.
- In MSE or Visual Studio, type the code that you want to run when the event occurs.
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