RegularExpressionValidator.ValidationExpression Property

Definition

Gets or sets the regular expression assigned to be the validation criteria. The default value is an empty string (""). This API is obsolete. For information about how to develop ASP.NET mobile applications, see Mobile Apps & Sites with ASP.NET.

C#
[System.ComponentModel.Bindable(true)]
public string ValidationExpression { get; set; }

Property Value

The regular expression assigned to be the validation criteria.

The RegularExpressionValidator does not perform validation on an empty string. To test for an empty string, use the RequiredFieldValidator and RegularExpressionValidator controls together.

Attributes

Exceptions

The regular expression assigned was malformed.

Remarks

The following table shows some sample validation expressions:

Type of Validation Validation Expression
Email \w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)
Phone number ((\d3 ?)|(\d{3}-))?\d{3}-\d{4}
URL http://([\w-]+\.)+[\w-]+(/[\w-./?%&=]*)?

Applies to

Product Versions
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

See also