MaskType in Xamarin Masked Entry (SfMaskedEdit)

Each MaskType has different set of mask characters that are combined to form a mask expression. Based on the complexity and usage, mask types are classified as:

  • Text
  • RegEx


The expressions that are generated with letters, digits, and special characters come under this group. This is mainly used for fixed length inputs. For example: phone number, zip code, and so on.

Text Mask characters



A Alphanumeric, required.
a Alphanumeric, optional.
L Letter, required. Restricts input to the ASCII letters a-z and A-Z.
l Letter, optional. Restricts input to the ASCII letters a-z and A-Z.
0 Digit, required. This character accepts any single digit between 0 and 9
9 Digit or space, optional.
# Digit or space, optional. Plus (+) and minus (-) signs are allowed.
C Character, optional.
\ Escapes a mask character, turning it into a literal. "\" is the escape sequence for a backslash.
Any other characters Considered as literals. Literals always occupy a static position in the mask at run time, and cannot be moved or deleted.
<syncmaskededit:SfMaskedEdit x:Name="maskedEdit" MaskType="Text" Mask="+1(000)000000"/>
SfMaskedEdit maskedEdit = new SfMaskedEdit();
maskedEdit.MaskType = MaskType.Text;
maskedEdit.Mask = "+1(000)000000";

This mask expression allows only numeric inputs in the places of 0.


The expressions that are generated with regular expressions come under this group, preferable for variable length inputs and input in range. For example: hexadecimal values [0-9A-C].
The regular expressions provide significant advantages when creating masks as compared with other mask modes.


  • Allows you to enter the value of indeterminate length.
  • Restricts with specific pattern. Example email, password, and more.
  • Restricts you to enter specific range at specific position.

Regex Mask Characters



\w Accepts any alphabet, number, including the _(Underscore) character.
\d Accepts any digit.
{n} Accepts the input for ‘n’ number of times.
{n,m} Accepts the input for ‘n’ minimum number of times and ‘m’ maximum number of times.
? Optional input.
+ Accepts the input for one or more times.
* Accepts the input for zero or more times.
[aeiou] Accepts any single character included in the specified set of characters.
[0-9a-fA-F] Accepts any character between[A-F]/[a-f] and numbers between [0-9].


SfMaskedEdit control only supports the above listed regex mask characters.

<syncmaskededit:SfMaskedEdit x:Name="maskedEdit" MaskType="RegEx" Mask="+1(\d{3})\d{5}"/>
SfMaskedEdit maskedEdit = new SfMaskedEdit();
maskedEdit.MaskType = MaskType.RegEx;
maskedEdit.Mask = @"+1(\d{3})\d{5}";

This mask expression ’\d{3}’ and’ \d{5}’ allows only numeric, where {n} is the count that the input should be accepted.

MaskType support in Xamarin.Forms masked edit