RadControls for WPF

The purpose of this tutorial is to show you how to use Standard mask with RadMaskedTextBox. Standard mask is a character based mask. You can specify the type of each character and set it to the following values:

  • Number
  • Letter
  • Fixed symbol
  • Any character

Setting Standard Mask

In order to use standard mask in RadMaskedTextBox, you need to set the RadMaskedTextBox's MaskType property to Standard.

CopyXAML
<telerik:RadMaskedTextBox MaskType="Standard" />

Masking Elements

This subsection describes the mask characters that can be used when the MaskType property is set to Standard.

  • 0 - digit, required. This element will accept any single digit between 0 and 9.
    CopyXAML
    <telerik:RadMaskedTextBox Mask="0000" MaskType="Standard" />
  • 9 - digit, required. This element will accept any single digit between 0 and 9.
    CopyXAML
    <telerik:RadMaskedTextBox Mask="9999" MaskType="Standard" />
  • # - digit or space, optional. If this position is blank in the mask, it will be rendered as the character in the Placeholder property. Plus (+) and minus (-) signs are allowed.
    CopyXAML
    <telerik:RadMaskedTextBox Mask="#######" MaskType="Standard" />
  • L - letter, required. Restrict input to the ASCII letters a-z and A-Z. This mask element is equivalent to [a-zA-Z] in regular expressions.
    CopyXAML
    <telerik:RadMaskedTextBox Mask="LLLL" MaskType="Standard" />
  • a - alphanumeric, optional. Accept any letter or digit.
    CopyXAML
    <telerik:RadMaskedTextBox Mask="aaaa" MaskType="Standard" />
  • l - accepts letters or space, optional.
    CopyXAML
    <telerik:RadMaskedTextBox Mask="llll" MaskType="Standard" />
  • \ - escape. Escapes a mask character, turning it into a literal. "\\" is the escape sequence for a backslash.
    CopyXAML
    <telerik:RadMaskedTextBox Mask="\#\\###" MaskType="Standard" />
  • Any other characters - literals. All non-mask elements will appear as themselves within RadMaskedTextBox. Literals always occupy a static position in the mask at run time, and cannot be moved or deleted by the user.
    CopyXAML
    <telerik:RadMaskedTextBox Mask="Number: ####" MaskType="Standard" />

See Also