MaskAttribute.Mask Property

Gets a mask expression.

Namespace: DevExpress.Web.Mvc

Assembly: DevExpress.Web.Mvc5.v21.1.dll


public string Mask { get; set; }

Property Value

Type Description

A string representing a mask expression.


Applying a mask to the editor restricts the text that end-users can enter. If masked mode is enabled, the editor validates the text against the mask, and only allows data that satisfies the mask expression to be entered. To enable masked mode for an editor, specify the mask using the Mask property.


The code sample below demonstrates how to decorate a model field with the Mask attribute.

namespace MyProject.Models
    using DevExpress.Web.Mvc;
    using System.ComponentModel.DataAnnotations;

    public class Customer
        // ...
        // Validates whether the input value satisfies the mask.
        [Mask("+1 (999) 000-0000", ErrorMessage = "The phone number is not valid!")]
        public string Phone { get; set; }
See Also