DataDOMEvent Object

Microsoft Office InfoPath

Show All Show All

DataDOMEvent Object

DataDOMEvent

An event object that is used during Microsoft Office InfoPath 2003 data validation events. The DataDOMEvent object provides a number of properties and a method that can be used within a data validation event to programmatically interact with the data that is being validated and to provide a response if the data is not valid.

Remarks

The DataDOMEvent object is passed as a parameter to the OnBeforeChange, OnValidate, and OnAfterChange events.

Note  The OnValidate event can occur without a change in the form's underlying XML document.

The DataDOMEvent object is used to get information about the XML Document Object Model (DOM) node that is being changed, and it also provides a property for getting a reference to a form's underlying XML document. In addition, it provides properties for handling the change in data, including rejecting the change and creating an error message.

Note  The DataDOMEvent object is passed as an argument to one of the data validation event handlers. Its properties and method are only available during the event that it is passed to.

Using the DataDOMEvent object

In the following example from the Data Validation developer sample form, the DataDOMEvent object is used to check the value of the node using the Site property. If the data validation fails, the ReportError method is used to create a custom error.

    function msoxd__itemB_quantityListB::OnValidate(eventObj)
{
   if (parseInt(eventObj.Site.nodeTypedValue, 10) > 50)
      eventObj.ReportError(eventObj.Site, "Invalid quantity.  " +
         "The total number of each type of block cannot exceed 50.", false);

   if (parseInt(eventObj.Site.nodeTypedValue, 10) < 0)
      eventObj.ReportError(eventObj.Site, "Invalid quantity.  " +
         "The total number of each type of block cannot be less than 0.", false);
}
  

For more information about using the DataDOMEvent object, see Responding to form events.