Data validation events in the Events developer sample form

Microsoft Office InfoPath

Show All Show All

Data validation events in the Events developer sample form

The Events developer sample form implements a variety of Microsoft Office InfoPath 2003 data validation events that can be used to validate data that is entered into a form. Data validation events can occur after a change has been made to a field or group, after a change has been made to a field or group but before the data is committed, and after a change has been made to a field or group and after the data is committed.

To use one of the data validation events, you must first create the event in the Field or Group Properties dialog box that is available from the Data Source task pane. To access this dialog box, right-click one of the fields or groups in the task pane, and then click Properties. On the Validation and Script tab, select the event you wish to create, and then click Edit; this opens Microsoft Script Editor (MSE) and displays the InfoPath-generated event handler.

Note  Event handlers in InfoPath must be created in design mode.

The following table lists each of the data validation events implemented in the Events developer sample form, along with a description of how they are used.

Event Description
OnValidate Used to validate the data contained in the ContactDates group. When this event occurs, scripting code is used to verify that the dates used are within a specified range.
OnBeforeChange Used to validate the data contained in the Email Campaign Start, Phone Contact Start, and Representative Visit date fields. When this event occurs, scripting code is used to implement business logic that checks for the existence of certain dates before others can be entered or removed.
OnAfterChange Used to call a function that calculates the total campaign costs and updates the Campaign Cost field.

ShowUsing the OnValidate event

ShowUsing the OnBeforeChange event

ShowUsing the OnAfterChange event