Skip to main content
A newer version of this page is available. .
Tab

RegularExpressionValidationPattern.ValidationExpression Property

Gets or sets the regular expression that specifies the pattern used to validate an editor.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v20.2.dll

NuGet Package: DevExpress.Web

Declaration

[DefaultValue("")]
public string ValidationExpression { get; set; }

Property Value

Type Default Description
String String.Empty

A string that specifies the regular expression used to validate an editor for formatting.

Remarks

Use this property to specify the pattern used to check for predictable sequences of characters, such as those in social security numbers, e-mail addresses, telephone numbers, and postal codes.

Regular expression validation of DevExpress editors covers all the editor text. That is, the regular expression defined via the ValidationExpression property is used to search for a match against the entire value of the validated editor (i.e., against the editor’s Text property value). Technically, it is similar to adding the “^” and “$” anchors at the beginning and the end of an expression (see Anchors in Regular Expressions).

Note

  • If the ValidationExpression property value is specified using lookbehind regular expression, the editor value is not validated on the client side as the lookbehind regular expressions are not supported by JavaScript.
  • The ValidationExpression property can accept only a validation patter, but not flags.

Example

View Example

<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 ValidationExpression 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.

See Also