aspnet-11126-components-data-editors-common-concepts-validation-validation-error-message.md
Editors can display an error message when the validation logic fails. Use the ErrorDisplayMode property to specify the elements (text, image, or frame) to display in the message.
| Property value | Elements that error message contains | Image |
|---|---|---|
ImageWithText | An error image and text. | |
ImageWithTooltip | An error image with a tooltip that displays the error text. | |
Text | An error text. | |
None | A frame. |
Use the Display property to specifies whether an editor renders an empty space for the error message initially or dynamically when the editor fails validation.
You can use the following properties to customize the error message elements:
ErrorFrameStyleSpecifies the error frame appearance.ErrorImageSpecifies the error image settings.ErrorTextSpecifies the default error text. If any specific validation type is used (such as the required field or regular expression validation) or a validation event is handled, the ErrorText property’s value can be overridden.
The table below lists validation types and settings that allow you to specify a particular error text related to the error type.
| Validation type | Validation rule member | Error text property |
|---|---|---|
| Required value | IsRequired | RequiredField.ErrorText |
| Regular expression | ValidationExpression | RegularExpression.ErrorText |
| Mask | Mask | MaskSettings.ErrorText |
| Custom validation | ASPxClientEdit.Validation / ASPxEdit.Validation | ASPxEdit.ErrorText |
You can override the error text in validation events.
Editors render error message settings on the client in the following ways:
false.If you need to validate an editor without using any predefined validation capabilities, set the ValidationSettings.EnableCustomValidation property to true to force the editor to render the error message elements on the client side.
function OnAgeValidation(s, e) {
// your validation logic
}
<dx:ASPxTextBox ID="ASPxTextBox1" runat="server" Width="170px" ClientInstanceName="tbAge">
<ValidationSettings ValidateOnLeave="False" EnableCustomValidation="True" />
</dx:ASPxTextBox>
<dx:ASPxButton ID="btnValidate" runat="server" AutoPostBack="False" Text="Validate">
<ClientSideEvents Click="OnAgeValidation" />
</dx:ASPxButton>
If an editor’s Native property is set to true, the editor is rendered in native mode as a standard HTML element. In this case, the editor is painted in browser’s native style and its appearance depends on the browser settings only. The style settings, such as ErrorDisplayMode or ErrorFrameStyle are not in effect.
See Also