MaskedTextBox Blazor API

MaskedTextBox Properties

NameTypeDefaultDescription
AllowPromptAsInputboolfalseDetermines whether promptChar can be entered as valid input by the user.
AsciiOnlyboolfalseDetermines whether the input accepts characters only from the ASCII character set.
AutoFocusboolfalseSpecifies whether the input should be focused when the page is loaded.
AutoShowMaskboolfalseDetermines whether the mask is shown/hidden on focus/blur even if placeholder is not set.
CutCopyMaskFormatMaskedTextBoxCutCopyMaskFormatMaskedTextBoxCutCopyMaskFormat.ExcludePromptAndLiteralsDetermines whether literals and prompt characters are copied to the clipboard on cut/copy operations.
DisabledboolfalseEnables or disables the element.
EnterKeyBehaviorEnterKeyBehaviorEnterKeyBehavior.SubmitSpecifies the behavior on "Enter" key press. Default mode is "submit".
HidePromptOnLeaveboolfalseDetermines whether the prompt character in the input mask is hidden when the masked text box isn't focused anymore.
Hintstring""Sets additional helper text below the element. The hint is visible only when the element is focused.
IsOverwriteModeboolfalseDetermines whether new user input overwrites the existing input value or not.
Labelstring""Sets label above the element. The label is always visible.
Localestring"en"Sets or gets the language. Used in conjunction with the property messages.
Maskstring"#####"Defines the mask for the input.
MaskCompletedboolfalseIndicates whether all required fields of the mask have been populated or not.
MaskFullboolfalseIndicates whether all required and optional fields of the mask have been populated or not.
MaxLengthint5Determines the maximum number of characters that the user can enter.
MessagesobjectN/ASets or gets an object specifying strings used in the widget that can be localized. Used in conjunction with the property locale.
Namestring""Sets or gets the name attribute for the element. Name is used when submiting HTML forms.
Placeholderstring""A string that appears inside the input when there's no value and mask.
PromptCharstring"_"Determines the prompt char that is used for the mask of the element.
ReadonlyboolfalseIf the element is readonly, the users cannot iteract with the element.
RejectInputOnFirstFailureboolfalseDetermines whether the parsing of user input should stop after the first invalid character or not.
RequiredboolfalseSpecifies that the input must be filled in before submitting a form
ResetOnPromptboolfalseDetermines whether an input character that matches the prompt character should reset the current selected value in the input or not. Applicable only when allowPromptAsInput is enabled.
ResetOnSpaceboolfalseDetermines whether hitting space character resets the currently selected value from the input or not.
RightToLeftboolfalseSets or gets the value indicating whether the element is aligned to support locales using right-to-left fonts.
SelectAllOnFocusboolfalseSpecifies whether the value of the input will be selected on focus or not.
TextMaskFormatMaskedTextBoxTextMaskFormatMaskedTextBoxTextMaskFormat.ExcludePromptAndLiteralsDetermines whether the value of the input should contain or not the prompt/literals of the mask.
Themestring""Determines the theme. Theme defines the look of the element
UnfocusableboolfalseIf is set to true, the element cannot be focused.
Valuestring""Sets or gets the value of the element.
ValidationobjectN/ACallback function that allows to set custom validation on the value. If the function returns false then the value of the input is treated as not valid.

MaskedTextBox Methods

NameTypeArgumentsDescription
GetValueAsync()Task<string>'N/A'Gets the &quot;Value&quot; property as Task&lt;string&gt;.
Refreshvoid'N/A'Refreshes the Blazor Component. Performs a layout of the HTML Elements and recalculates the measurements.
Rendervoid'N/A'Re-renders the Blazor Component. This method will make a full re-render.
StateHasChangedvoid'N/A'Refreshes the state and Re-renders the Blazor Component, if necessary.

MaskedTextBox Events

NameTypeDescriptionEvent Detail
OnChangeEventCallback<Event>This event is triggered when the value of the Text Box is changed.dynamic oldValue- The previous value before it was changed., dynamic value- The new value.
Changedevent MaskedTextBoxChangedEventHandlerThis event is triggered when the value of the Text Box is changed.MaskedTextBoxChangedEventArgs
OnChangingEventCallback<Event>This event is triggered on each key up event of the MaskedTextBox, if the value is changed.dynamic oldValue- The previous value before it was changed., dynamic value- The new value.
Changingevent MaskedTextBoxChangingEventHandlerThis event is triggered on each key up event of the MaskedTextBox, if the value is changed.MaskedTextBoxChangingEventArgs
OnValidationEventCallback<Event>This event is triggered if the <b>validation</b> property is set. Indicates whether valiation has passed successfully or not.dynamic success- A flag inidicating whether the validation was successfull or not.
Validationedevent MaskedTextBoxValidationedEventHandlerThis event is triggered if the <b>validation</b> property is set. Indicates whether valiation has passed successfully or not.MaskedTextBoxValidationedEventArgs

Enums

MaskedTextBoxCutCopyMaskFormat

MaskedTextBoxCutCopyMaskFormat.ExcludePromptAndLiterals
MaskedTextBoxCutCopyMaskFormat.IncludePrompt
MaskedTextBoxCutCopyMaskFormat.IncludeLiterals
MaskedTextBoxCutCopyMaskFormat.IncludePromptAndLiterals

EnterKeyBehavior

EnterKeyBehavior.ClearOnSubmit
EnterKeyBehavior.Submit

MaskedTextBoxTextMaskFormat

MaskedTextBoxTextMaskFormat.ExcludePromptAndLiterals
MaskedTextBoxTextMaskFormat.IncludePrompt
MaskedTextBoxTextMaskFormat.IncludeLiterals
MaskedTextBoxTextMaskFormat.IncludePromptAndLiterals