Search results

Getting Started

This section briefly explains about how to include a simple MaskedTextBox in your ASP.NET Core application. You can refer ASP.NET Core Getting Started documentation page for introduction part part of the system requirements and configure the common specifications.

Adding component to the Application

MaskedTextBox component can be rendered by using the ejs-maskedtextbox tag helper in ASP.NET Core application. Add the below simple code to your index.cshtml page which is available within the Views/Home folder, to initialize the MaskedTextBox.

The following example shows a basic MaskedTextBox component.

tagHelper
gettingstarted.cs
@section ControlsSection{

<ejs-maskedtextbox id="mask1" ></ejs-maskedtextbox>

}
public ActionResult Demo()
{
    return View();
}

Set the mask

You can set the mask to the MaskedTextBox to validate the user input by using the mask property. To know more about the usage of mask and configuration, refer to this link.

The following example demonstrates the usage of mask element 0 that allows any single digit from 0 to 9.

tagHelper
mask.cs
@section ControlsSection{

<ejs-maskedtextbox id="mask1" mask="000-000-0000" placeholder="MaskedTextBox" floatLabelType="Always" ></ejs-maskedtextbox>

}
public ActionResult Mask()
{
    return View();
}

Output be like the below.

MaskedTextBox Sample

See Also