Class DateMask
- Namespace
- MudBlazor
- Assembly
- MudBlazor.dll
An input pattern mask which accepts date values.
public class DateMask : PatternMask, IMask
- Inheritance
-
DateMask
- Implements
- Inherited Members
- Extension Methods
Remarks
Date masks consist of a combination of: days (e.g. dd), months (e.g. MM), and years (e.g. yy or yyyy), and any delimiter. Custom characters can be used to represent days, months, and years.
Examples: yyyy-MM-dd, MM/dd/yyyy, MM/yy. If custom characters are used, replace the letter blocks with custom characters.
Constructors
DateMask(string, char, char, char)
Creates a new date mask.
public DateMask(string mask, char year = 'y', char month = 'M', char day = 'd')
Parameters
maskstringThe mask to use. Days must be a two-letter block (e.g.
dd), months must be a two-letter block (e.g.MM), and years must be a two- or four-letter block (e.g.yyoryyyy).
If custom characters are used for days, months, or years, change the blocks to use these custom characters.
Examples:yyyy-MM-dd,MM/dd/yyyy,MM/yy.yearcharDefaults to
y. The character which represents years.monthcharDefaults to
M. The character which represents months.daycharDefaults to
d. The character which represents days.
Remarks
Date masks consist of a combination of: days (e.g. dd), months (e.g. MM), and years (e.g. yy or yyyy), and any delimiter.
Examples: yyyy-MM-dd, MM/dd/yyyy, MM/yy. If custom characters are used, replace the letter blocks with custom characters.
Methods
ModifyFinalText(string)
Adjusts the input to be valid for special situations, such as when the last character input results in an invalid date.
protected override string ModifyFinalText(string text)
Parameters
textstring
Returns
Remarks
Only takes effect for complete dates.
For example: for mask MM/dd/yyyy, text of 02/29/202_, and a character input of 3, the resulting date 02/29/2023 would be invalid because 2023 is not a leap year.
Another example: for mask MM/dd/yyyy, text of 0_/31/2023, and a character input of 4, the resulting date 04/31/2023 would be invalid because April 31st, 2023 does not exist.
ModifyPartiallyAlignedMask(string, string, int, ref int, ref int, ref string)
protected override void ModifyPartiallyAlignedMask(string mask, string text, int maskOffset, ref int textIndex, ref int maskIndex, ref string alignedText)
Parameters
UpdateFrom(IMask)
Copies the mask and mask characters from the specified mask.
public override void UpdateFrom(IMask other)
Parameters
otherIMaskThe mask to copy from.