The field-type validations
A good web form usually contains one or more validations for one or more of its fields. A validation is a programmatically hard-coded condition that specifies whether the text you enter in a field of a web form can be accepted as a valid value. If the text entered does not conform to the predefined format, an error message is displayed in the web form field.
In the Web Forms for Marketers module, validations on a field type apply to all forms that use fields of that type (for example, Single-Line text) and these change if you change the field type, whereas form-specific validations stay with the field regardless of field-type.
The module supports web forms (.aspx) and MVC (.cshtml) layouts. Under field-type validations, both web forms and MVC are implemented in different ways. For web forms, a field type validation consists of a code and items that are stored in the content tree, in the validation item sitecore/system/modules/Web Forms for Marketers/settings. For MVC, a field type validation consists only of a code and does not use the validation item structure. Each field type contains predefined built-in validations relevant for the particular field type, for example: email, phone number, or credit card validations.
You can add a new, custom field type validation or custom form-specific field validation to a form, you can assign more than one validation to a field type, or you can remove them according to your needs.
Field-type validations for web forms:
|
Validation |
Description |
Used by field type |
|---|---|---|
|
Count chars |
Checks the number of characters in a string. You can set the minimum and maximum number of characters. |
Single-Line Text Multiple-Line Text Password Password-Confirmation |
|
Date |
Checks whether the value entered is a date. |
Date |
|
|
Checks whether the value entered uses the format of an email address. |
|
|
Is Iso Date |
Checks whether the value entered is an ISO date. | |
|
Number |
Checks whether the values entered are numbers (negative numbers and integers are allowed). |
Number |
|
Number range |
Checks whether the values entered are within a specified range of numbers. |
Number |
|
Regex pattern |
Checks whether the values entered conform to a rule that you specify. |
Single-Line Text Multiple-Line Text Password Password-Confirmation |
|
Telephone |
Checks whether the value entered is a valid telephone number. |
Telephone |
|
SMS/MMS Telephone |
Checks whether the value entered is a valid format for a text message or an MMS. |
SMS/MMS Telephone |
|
Luhn formula American Express, Diners Club Carte Blanche, Diners Club International, Diners Club US and Canada, JCB, Maestro, MasterCard, Solo, Switch, Visa, Visa Electron |
Checks the validity of a credit card number based on the type of credit card. |
Credit card |
|
Compare Password - Confirmation |
Compares the values entered in the Password and Confirmation fields. |
Password-Confirmation |
|
Captcha |
Compares the text displayed in a CAPTCHA field with the value entered by the user. |
Captcha |
|
Robot Protection |
Checks whether a current visitor is a robot (using the robot detection algorithm). |
Captcha |
|
Suspicious Visitor |
Identifies a website visitor who submits a web form several times during a short period of time as suspicious. |
Captcha |
|
Suspicious Form Activity |
Identifies the form activity as suspicious if a web form is submitted several times during a short period of time by one or many users. |
Captcha |
Field-type validation attributes for MVC:
|
Description |
Model name |
Attributes |
|---|---|---|
|
Checks the validity of a credit card number based on the type of credit card. |
CreditCardField |
RequestResponse |
|
Checks whether or not the value entered is a date. |
DateField |
RequestResponse |
|
Checks whether or not the value entered uses the format of an email address. |
EmailField |
RequestResponse |
|
Checks whether or not the values entered are numbers (negative numbers and integers are allowed). Also checks whether or not the values entered are within a specified range of numbers. |
NumberField |
RequestResponse |
|
Compares the values entered in the Password and Confirmation fields. |
PasswordConfirmationField |
RequestResponse |
|
Compares the text displayed on an image or sound voiced by a speaker with the value entered by the user. |
RecaptchaField |
RequestResponse |
|
Checks whether or not the text in a field is within the specified min and max length. |
SingleLineTextField |
RequestResponse |
|
Checks whether or not the text is an SMS number |
SmsTelephoneField |
RequestResponse |
|
Checks whether or not the text is a phone number |
TelephoneField |
RequestResponse |