Open kevinvenclovas opened 3 years ago
no. text field accepts string as value. but we can restrict type to number and parse the value from string as below.
<TextField
Id="fillted-number"
Label="Number"
Value="@Age?.ToString()"
OnChange="@HandleAgeChange"
Type="number"
Class="demo-text-field"
Margin="@Margin.Normal"
Variant="@TextFieldVariant.Filled" />
private void HandleAgeChange(ChangeEventArgs args)
{
if (int.TryParse(args.Value?.ToString(), out int age))
{
Age = age;
StateHasChanged();
}
}
Is there a component to bind a double or decimal to an input field?
@skclusive