Microsoft SharePoint InfoPath form provides some types of Rules to perform the action on the controls of the form. Validation Rule is one on them. InfoPath form automatically validates the data you entered and if does not match with the required condition, it fires the error message. To validate the data of the field, we use the Validation Rule. This Rule prevents your form from the invalid or empty data until the error does not fix. Validation Rule also provides the ability to create a user-friendly message. This Rule can be applied to any field, on Page Load event or any Button’s onclick event.
Appearance of Validation message
The error message can be displayed in either of the following 2 ways:
In line error message: In line error message displays the message with the control. It highlights the control with the red dashed border when the data of control does not match with the required condition.
Dialog box error message: Dialog box error message opens a dialog and displays the message in that dialog when the data of control does not match with the required condition.
Setting a condition on a Rule
To apply the Validation Rule for the field’s data, it is mandatory to set the required condition. For single field’s validation, you can apply the multiple conditions using “And” or “Or” operators. Below is demonstrated to set a Validation Rule on the field:
1) Open the InfoPath form and select the control on which you want to apply the Validation Rule.
2) When you selected the control, then on top ribbon of InfoPath designer, you will get the “Manage Rules” option under “Home” tab. Click on “Manage Rules” button.
3) A “Rules” window will get open on right to the InfoPath designer.
4) Open the “New” dropdown and select the “Validation” option.
5) In “Details for” section, you can add the name of your rule.
6) Click on “None” link in “Condition” section, a “Condition” dialog will get open.
7) First, down-down will show you all the fields of the form. Select the field name which field’s data you want to validate.
8) Next, select the condition which you wanted to be apply on the field. There is an “And” operator button provided to apply the multiple conditions on the field and validate the data. Now click “OK” to save the condition.
9) In “ScreenTip” box, write the error message you which you want to display on UI of the form.
10) In the Rules window, there is a link “Show more options”. When you click on that you will get the option to show the error message in the dialog box.
Save and publish the form
After applying the Rule to the control, save and publish the form in the Form library. Now, when you will going to submit the form and the required condition does not match then it will fire the error message.