Set up and create a form-specific field validation
Create and set-up an extended set of validations applied directly on a field of a specific form.
In addition to field-type validations, the Web Form for Marketers module includes form-specific field validations that are an extended set of validations applied directly on a field of a specific form.
Using a form-specific field validation makes it simple to add the most frequently used types of validations to fields in your new or existing web forms. You can also add a new, form-specific field validator to the list of existing validations, making it easier and faster to select it next time you want to assign a validation to a form.
For example, in a field where you want users to only enter numbers, you can select the Numbers Only validation to display an error message if they enter symbols or letters.
You can find the list of default field validators in the content tree in the /sitecore/system/Modules/Web Forms for Marketers/Settings/Meta data/Predefined Validators
folder.
The rules that define a validation are displayed in the Regular Expression field, and they are fixed. However, if you create a custom form-specific field validation, you can manually configure the regular expression.
This topic outlines the following procedures:
Open the Form Designer, and in the Select a Form dialog box, choose the form that you want to set up, and click OK.
In the Form Designer, click the relevant field where you want to add the validator, for example, Single-Line text.
In the left pane, in the Validation section, click the drop-down arrow in the Validation field and select the relevant validator from the list, for example, Numbers only. The Regular Expression field is filled in automatically.
In the Error Message field, you can customize the message that appears if a user enters the wrong values.
Specify the minimum and maximum length of the numbers of characters allowed in the form. If the number of characters entered in the field on the web form is greater than the number specified in the Maximum Length field, an error message appears.
Note
Each field can have a set of validations. On the left pane, under the Validation section users can also choose a custom validation. These settings work in combination with validations assigned to the field type.
Click Save.
To create a new, predefined form-specific field validator and add it to the list:
On the Sitecore Desktop, open the Content Editor, and navigate to the
sitecore/System/Modules/Web Forms for Marketers/Settings/Meta data/Predefined Validators
folder.On the Folder tab, in the Options section click Extended List Item. Alternatively, in the ribbon, on the Home tab, in the Insert group, click Extended List Item.
In the Message dialog box, enter a name for the new item and click OK.
Click the Content tab, and in the Data section, in the Value field, fill in the appropriate value in the format of a regular expression. For example, for a Numbers only validation:
^[-,+]{0,1}\d*\.{0,1}\d+$
Click Save to save your changes.
The new form-specific field validator is now displayed in the list of validations in the Form Designer.