Mask
- 2 minutes to read
DevExpress editors allow you to use masks when users edit data. Masks are useful when you require a user to enter a string in a specific format. For instance, a text editor that accepts date/time values in the 24-hour format only, or a phone number that requires a user to enter digits into automatically constructed placeholders.
You can use masked input in the following ASP.NET editor types (ASPxEditors):
Text box editors (in particular, the ASPxTextBox and ASPxButtonEdit).
You can use the ASPxTextBox.MaskSettings (ASPxButtonEdit.MaskSettings) property to access mask settings. Use the MaskSettings.Mask property to specify the editor’s mask.
<dx:ASPxTextBox ID="textBox" > <MaskSettings Mask="00000" ErrorText="Please input missing digits" /> </dx:ASPxTextBox>
Date editors (ASPxDateEdit).
Set the ASPxDateEdit.UseMaskBehavior property to
true
to enable masked input in a date editor. You can use the ASPxDateEdit.EditFormatString property to define the mask, if the ASPxDateEdit.EditFormat property is set to EditFormat.Custom.<dx:ASPxDateEdit ID="dateEdit" EditFormat="Custom" EditFormatString="MMMM dd, yyyy" UseMaskBehavior="true" > ... </dx:ASPxDateEdit>
Note
If you use the editor’s MaskSettings.Mask property to define a text box editor’s mask, it automatically activates the editor’s built-in validation functionality. This might affect the editor’s appearance, because extra space may be required to display an error image and text (for invalid input), due to an editor’s default validation settings. To customize the editor appearance in this case, use validation properties available from the editor’s ASPxEdit.ValidationSettings property (for instance, you can modify the ValidationSettings.Display or ValidationSettings.ErrorDisplayMode property). You can also use an editor’s MaskSettings.ErrorText property to display mask-specific error text.