Mask Support in Blazor DatePicker
27 Aug 20261 minute to read
The masking feature helps users enter a date in the correct format by rendering the input as a mask that follows the configured Format property. Set EnableMask to true to enable masking. The default value of EnableMask is false.
@using Syncfusion.Blazor.Calendars
<SfDatePicker TValue="DateTime?" EnableMask="true" @bind-Value="@Value">
<DatePickerMaskPlaceholder Day="day" Month="month" Year="year"></DatePickerMaskPlaceholder>
</SfDatePicker>
@code {
public DateTime? Value { get; set; } = new DateTime(2022, 12, 11);
}
MaskPlaceholder
The DatePickerMaskPlaceholder directive sets the placeholder text for each segment (day, month, year) of the masked input.
The DatePickerMaskPlaceholder directive exposes the following properties:
-
Day: Specifies the placeholder text for the day segment of the date value (matches the
dorddformat specifier). -
Month: Specifies the placeholder text for the month segment of the date value (matches the
MorMMformat specifier). -
Year: Specifies the placeholder text for the year segment of the date value (matches the
yyoryyyyformat specifier).
By default, the Blazor DatePicker loads placeholder text from the current culture’s resources file for each segment. To override the default, specify the segments you want through the DatePickerMaskPlaceholder directive.
@using Syncfusion.Blazor.Calendars
<SfDatePicker TValue="DateTime?" EnableMask="true" @bind-Value="@Value">
<DatePickerMaskPlaceholder Day="day" Month="month" Year="year"></DatePickerMaskPlaceholder>
</SfDatePicker>
@code {
public DateTime? Value { get; set; } = new DateTime(2022, 12, 11);
}
NOTE
If you do not specify custom placeholder text for a particular segment, the component uses the default placeholder text from the current culture’s resource file for that segment.
See also
- Date Format
- EnableMask property
- Format property
- StrictMode property