Masked Input Overview
- 3 minutes to read
The DXEditors for Silverlight library allows you to use masks during editing. Masks restrict data input, as well as format data output.
Using masks in editors is useful when the entered string should match a specific format. For instance, a text editor should accept date/time values in 24-hour format only or only numeric values. Another example is entering a phone number within an editor (an end-user needs to enter only digits, while hyphens should be automatically skipped while editing). To support these and many other data input formats, the masked mode can be used.
Our text editors fully support the following mask types.
Numeric
This mask type is the best choice when you need to restrict input to numeric values. The mask is specified using simple .NET Framework format strings. If you need to restrict input to currency values, you can simply specify the one-character "c" mask. No literal characters will be allowed, nor will the mask allow more than two digits after the decimal point. End-users will be able to navigate through digits and increase or decrease their values using UP and DOWN arrows or the mouse wheel.
Date-Time
This mask type has a lot in common with the Numeric mask and is used for date-time values. You also specify the mask using .NET Framework format strings, and the same end-user capabilities are available. They include navigation between value sections (days, months, years, hours, etc.) and incremental value modifications using the keyboard and mouse wheel.
Simple Masks
This mask type is the best when you need to enter strings of limited length, such as phone numbers, zip codes, social security numbers, etc. The mask is specified using a sequence of characters. Some characters serve as placeholders for digits or letters, while others are literals used to separate value sections. An example of such literals is parentheses for the area code in a phone number.
Regular Expression Masks
If the mask types listed above do not meet your business requirements, you can use regular expressions that have no limitations - any regular expression can be used as a mask.
The DXEditors for Silverlight demo application includes separate modules for each mask type, so you can see all of them in action.
#General Information
An editor's mask settings can be defined using the properties that have the 'Mask' prefix (such as the TextEdit.MaskType, TextEdit.Mask, TextEdit.MaskCulture, etc.). Masks are usually used in edit mode. When an editor is not in edit mode, its display text can be also formatted using a specified mask, if the TextEdit.MaskUseAsDisplayFormat property is set to true. If this property is set to false, an editor's display text is composed using the BaseEdit.DisplayFormatString pattern in display mode.
Masked input is not supported by the following editors (TextEdit descendants): ComboBoxEdit, LookUpEdit, MemoEdit, PopupColorEdit and PopupImageEdit.
#Design-Time Enhancements
The Mask Editor allows you to quickly create and customize masks of any complexity at design-time.