System.Web.UI.WebControls.RegularExpressionValidator.ValidationExpression Property

Gets or sets the regular expression that determines the pattern used to validate a field.

Syntax

[System.ComponentModel.Editor("System.Web.UI.Design.WebControls.RegexTypeEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(System.Drawing.Design.UITypeEditor))]
[System.ComponentModel.DefaultValue("")]
[System.Web.UI.Themeable(false)]
public string ValidationExpression { set; get; }

Value

Documentation for this section has not yet been entered.

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.

The System.Web.UI.WebControls.RegularExpressionValidator does not perform validation on an empty string. If the string you are testing might be empty, use the System.Web.UI.WebControls.RequiredFieldValidator as well as the System.Web.UI.WebControls.RegularExpressionValidator.

For more information on regular expressions, see .NET Framework Regular Expressions.

Note:

If you experience problems with pattern matching constructs, try wrapping the expression with "^(" and ")$". For example, "a|ab" becomes "^(a|ab)$".

This property cannot be set by themes or style sheet themes. For more information, see System.Web.UI.ThemeableAttribute and ASP.NET Themes Overview.

Requirements

Namespace: System.Web.UI.WebControls
Assembly: System.Web (in System.Web.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0