About data validation
Data validation can be used to display error alerts when users enter incorrect values into a form. Rather than checking for errors after a form is completed, data validation verifies values as the form is being filled out.
Working with data validation when filling out a form
Microsoft Office InfoPath 2003 automatically checks the data you type into a form and displays an error alert if the value does not match the condition specified by the data validation rule. If a value you enter does not match the specified condition, an error alert provides you with immediate feedback.
Error alerts can be either dialog box alerts or inline alerts. You can correct errors immediately, or you can use the commands on the Tools menu to navigate through and correct all the errors in a form at once. Uncorrected errors are marked with a dashed red border. Required entries are marked with a red asterisk or, for some types of controls, a dashed red border. To see details about the error, you can right-click the control.
If you save a form without fixing the errors, you will be reminded about the errors with a dialog box alert. You can save forms with validation errors, but you cannot submit them.
Working with data validation when designing a form
Data validation is always associated with a specific control and occurs when a user fills out a form. Note that InfoPath verifies a condition by checking the value of the field that is bound to the control, not the control itself.
- Required fields Requires users to enter a value into a control.
- Data-type validation Requires users to enter a particular type of data, such as whole numbers or dates, into a control.
- Range checking Ensures that the value entered into a control is within the specified range. For example, range checking can limit an expense item to less than $500.
- Dynamic comparisons Compares values in different controls. For example, dynamic comparisons can require a shipping date to occur after an order date.
- Data patterns Requires users to type values in a specific pattern, such as a phone number.
- Code-based validation Uses custom code to perform advanced validation on a control.
When you add data validation to a control, you can specify one of two types of error alerts to display to users:
- Inline alert Marks controls that contain invalid data with a dashed red border. The user can right-click the control to display a standard or custom error message.
- Dialog box alert Opens a dialog box with a custom error message when invalid data is entered into a control. If the user does not fix the error immediately the control is marked with an inline alert.
If your form is based on a pre-existing XML Schema, InfoPath automatically validates data entries based on the schema constraints. In some cases, these constraints are similar to or the same as the standard data validation available in InfoPath; data-type validation, for example, is a kind of schema-based validation. In other cases, the pre-existing schema may contain more extensive validation, including advanced data types. Error alerts for schema-based validation appear as standard inline alerts.
To test a data validation constraint, including the conditions and error alerts, preview your form and enter valid and invalid data into the control you want to test. Error alerts will appear in the preview exactly as they appear to your users.
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