MaskType
Each MaskType has different set of mask elements that are combined to form a mask expression. Based on the complexity and usage, mask types are classified as,
- Simple
- Regular
- Reg-Ex
Simple
Expressions that are generated with very simple mask elements come under this group. This is mainly used for fixed length inputs. For example: Phone number.
Mask elements in this mask type are as follows:
Simple mask elements
Elements | Description |
---|---|
0 | Digit, required. This element accepts any single digit between 0 and 9. |
9 | Digit or space, optional. |
# | Digit or space, optional. Plus (+) and minus (-) signs are allowed. |
L | Letter, required. Restricts input to the ASCII letters a-z and A-Z. This mask element is equivalent to [a-z A-Z] in regular expressions. |
? | Letter, optional. Restricts input to the ASCII letters a-z and A-Z. This mask element is equivalent to [a-z A-Z]? in regular expressions. |
C | Character, optional. |
A | Alphanumeric, required. |
< | Shift down. Converts all the characters that follow to lowercase. |
> | Shift up. Converts all the characters that follow to uppercase. |
Regular
Expressions that are generated with slightly complex mask elements are under this group, preferable for variable length inputs and input in range. For example: Hexadecimal values [0-9A-C].
Regular mask elements
Elements | Description |
---|---|
\w | Accepts any alphabet. |
\d | Accepts any digit. |
[0-9A-Z] | Accepts any digit between 0-9 and character between A-Z. |
{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. |
RegEx
Very complex regular expressions come under this category. It accepts input of variable length and allows to use OR expressions.
RegEx mask elements
Elements | Description |
---|---|
abc|def | Accepts any one input that matches. |
(a|b)+ | Accepts the matching input one or more times. |
For example: The following code example shows the validation for E-mail using Regex Elements.
<syncfusion:SfMaskedEdit x:Name="sfMaskedEdit" MaskType="RegEx" Mask="[A-Za-z0-9._%-]+@[A-Za-z0-9]+.[A-Za-z]{2,3}" Value="someone@example.com" />