Search results

Getting Started

This section briefly explains how to include a simple MaskedTextBox in your Blazor client-side application. You can refer to the Getting Started with Syncfusion Blazor for Client-side in Visual Studio 2019 Preview page for introduction part of the system requirements and configure the common specifications.

Importing Syncfusion Blazor component in the application

  1. Install the Syncfusion.EJ2.Blazor NuGet package to the application by using the NuGet Package Manager. Ensure to check the Include prerelease option.

  2. You can add the client-side resources through CDN or local npm package to the <head> element of the ~/wwwroot/index.html page.

<head>
    <link href="https://cdn.syncfusion.com/ej2/17.3.29/material.css" rel="stylesheet" />
    <script src="https://cdn.syncfusion.com/ej2/17.3.29/dist/ej2.min.js"></script>
</head>

If you are using server-side application, add required resources to the ~/Pages/_Host.html page.

Adding component package to the application

Import the Syncfusion.EJ2.Blazor.Inputs packages in ~/_Imports.razor file.

@using Syncfusion.EJ2.Blazor

@using Syncfusion.EJ2.Blazor.Inputs

Adding MaskedTextBox component to the application

Now, add the Syncfusion Blazor MaskedTextBox component to any razor page in the Pages folder. For example, the MaskedTextBox component is added in the ~/Pages/Index.razor page.

<EjsMaskedTextBox></EjsMaskedTextBox>

The output will be as follows.

MaskedTextBox Sample

Set the mask

You can set the mask to the MaskedTextBox to validate the user input by using the Mask property. The following example demonstrates the usage of mask element 0 that allows any single digit from 0 to 9.

<EjsMaskedTextBox Mask='000-000-0000'></EjsMaskedTextBox>

The output will be as follows.

MaskedTextBox Sample

See Also