Back to Devexpress

RegularExpressionValidationPattern.ErrorText Property

aspnet-devexpress-dot-web-dot-regularexpressionvalidationpattern.md

latest5.8 KB
Original Source

RegularExpressionValidationPattern.ErrorText Property

Gets or sets the error text to be displayed within the editor’s error frame if the editor’s specific regular expression validation fails.

Namespace : DevExpress.Web

Assembly : DevExpress.Web.v25.2.dll

NuGet Package : DevExpress.Web

Declaration

csharp
[DefaultValue("Regular expression validation failed")]
public override string ErrorText { get; set; }
vb
<DefaultValue("Regular expression validation failed")>
Public Overrides Property ErrorText As String

Property Value

TypeDefaultDescription
String"Regular expression validation failed"

A String value that specifies the error text.

|

Remarks

The ErrorText property allows you to specify an error text to be displayed if the editor’s specific regular expression (specified via the RegularExpressionValidationPattern.ValidationExpression property) validation fails. If the property value is empty, the ValidationSettings.ErrorText property value is used instead.

You can override an error text within validation events, via the ASPxClientEditValidationEventArgs.errorText parameter of the client-side ASPxClientEdit.Validation event or via the ValidationEventArgs.ErrorText parameter of the server-side ASPxEdit.Validation event.

To learn more, see the Validation Error Message topic.

Example

aspx
<dx:ASPxTextBox ID="tbEMail" runat="server" Size="49" NullText="Enter e-mail ..." Font-Size="Small">
    <ValidationSettings EnableCustomValidation="True" ErrorDisplayMode="Text" ErrorTextPosition="Bottom" SetFocusOnError="true">
        <ErrorFrameStyle Font-Size="Smaller"/>
        <RegularExpression ValidationExpression="^\w+([-+.'%]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$" 
            ErrorText="Invalid e-mail"/>
        <RequiredField IsRequired="True" ErrorText="E-mail is required"/>
    </ValidationSettings>
    <NullTextStyle Font-Size="Small"/>
</dx:ASPxTextBox>
aspx
<dx:ASPxTextBox ID="tbEMail" runat="server" Size="49" NullText="Enter e-mail ..." Font-Size="Small">
    <ValidationSettings EnableCustomValidation="True" ErrorDisplayMode="Text" ErrorTextPosition="Bottom" SetFocusOnError="true">
        <ErrorFrameStyle Font-Size="Smaller"/>
        <RegularExpression ValidationExpression="^\w+([-+.'%]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$" 
            ErrorText="Invalid e-mail"/>
        <RequiredField IsRequired="True" ErrorText="E-mail is required"/>
    </ValidationSettings>
    <NullTextStyle Font-Size="Small"/>
</dx:ASPxTextBox>

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the ErrorText property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

xaf-how-to-show-a-hyper-link-url-email-etc-for-a-business-class-property/CS/HyperLinkPropertyEditor.Web/WebHyperLinkStringPropertyEditor.cs#L26

csharp
textBox.ValidationSettings.RegularExpression.ValidationExpression = UrlEmailMask;
textBox.ValidationSettings.RegularExpression.ErrorText = UserVisibleExceptionLocalizer.GetExceptionMessage(UserVisibleExceptionId.MaskValidationErrorMessage);
textBox.TextChanged += EditValueChangedHandler;

xaf-how-to-show-a-hyper-link-url-email-etc-for-a-business-class-property/VB/HyperLinkPropertyEditor.Web/WebHyperLinkStringPropertyEditor.vb#L28

vb
textBox.ValidationSettings.RegularExpression.ValidationExpression = UrlEmailMask
textBox.ValidationSettings.RegularExpression.ErrorText = UserVisibleExceptionLocalizer.GetExceptionMessage(UserVisibleExceptionId.MaskValidationErrorMessage)
AddHandler textBox.TextChanged, AddressOf EditValueChangedHandler

See Also

Validation

Validation Error Message

RegularExpressionValidationPattern Class

RegularExpressionValidationPattern Members

DevExpress.Web Namespace