Validation Settings
- 2 minutes to read
The following properties specify validation criteria to define editor validation logic:
- The ValidationSettings.RequiredField property allows you to indicate that a field is required.
- The ValidationSettings.RegularExpression property allows you to validate an editor’s value based on a regular expression.
- The MaskSettings.Mask property allows you to specify an editor mask expression.
You can specify an error message based on validation criteria. See the following help topic to learn more: Validation Error Message.
Set the ValidationSettings.SetFocusOnError property to true
to automatically move the input focus back to the editor’s input region when editor validation fails. This allows the user to update the editor’s invalid value.
Editor validation can start automatically after a user changes an editor value if the ValidationSettings.ValidateOnLeave property is set to true
.
A DevExpress editor’s API allows you to work with a group of editors - a validation group. Groups allow you to assign validation editors on a page to a specific category. Each validation group can be validated independently from other validation groups on the page. Use the ValidationSettings.ValidationGroup property to specify the name of the validation group for a particular editor.
An editor can validate an entire editor group if the editor’s ValidationSettings.CausesValidation property is set to true
.
Example
<dx:ASPxTextBox ID="tbEmail" runat="server">
<ValidationSettings>
<RequiredField ErrorText="E-mail is required" IsRequired="True" />
<RegularExpression ErrorText="Invalid e-mail" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" />
</ValidationSettings>
</dx:ASPxTextBox>