ASP.NET Core Blazor [Preview]
Search results

Getting Started

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

Adding component package to the application

Open ~/_Imports.razor file and import the Syncfusion.EJ2.RazorComponents.Inputs packages.

@using Syncfusion.EJ2.RazorComponents
@using Syncfusion.EJ2.RazorComponents.Inputs

Adding NumericTextBox component to the application

Now, add the Syncfusion Essential JS 2 NumericTextBox component in any web page razor in the Pages folder. For example, the NumericTextBox component is added in the ~/Pages/Index.razor page.

  <EjsNumericTextBox id="numeric" value="10"></EjsNumericTextBox>

Run the application

After successful compilation of your application, simply press F5 to run the application.

Output be like the below.

NumericTextBox Sample

Range validation

You can set the minimum and maximum range of values in the NumericTextBox using the min and max properties, so the numeric value should be in the min and max range.

The validation behavior depends on the strictMode property.

The below example demonstrates range validation.

  <EjsNumericTextBox id="numeric" value="0.5" max="1" min="0" step="0.01"></EjsNumericTextBox>

Formatting the value

User can set the format of the NumericTextBox component using format property. The value will be displayed in the specified format, when the component is in focused out state.

The below example demonstrates format the value by using currency format value c2.

  <EjsNumericTextBox id="numeric" value="10" format="c2"></EjsNumericTextBox>

Precision of numbers

You can restrict the number of decimals to be entered in the NumericTextBox by using the decimals and validateDecimalOnType properties. So, you can’t enter the number whose precision is greater than the mentioned decimals.

  • If validateDecimalOnType is false, number of decimals will not be restricted. Else, number of decimals will be restricted while typing in the NumericTextBox.

    <EjsNumericTextBox id="strict" value="10" validateDecimalOnType="true" decimals="3" format="n3" placeholder="ValidateDecimalOnType enabled" floatLabelType="Auto"></EjsNumericTextBox>
    <EjsNumericTextBox id="allow" value="10" decimals="3" format="n3" placeholder="ValidateDecimalOnType disabled" floatLabelType="Auto"></EjsNumericTextBox>