Field validation problem in ASP.NET Core

Asked

Viewed 214 times

1

The field Unit Value accepts only 3 digits after the comma. I need it to accept 4 decimal places. I wonder what might be causing this restriction regarding the formatting of this field.

The code I have implemented is this below:

Viewmodel

[Required(ErrorMessage = "O campo Valor Unitário é obrigatório.")]
[Column("ValorUnitario")]
[DataType(DataType.Currency)]
[Display(Name = "Valor unitário *")]
public double ValorUnitario { get; set; }

Front-end

<div class="form-group">
    <label asp-for="@Model.ValorUnitario" class="control-label"></label>
    <input asp-for="@Model.ValorUnitario" class="form-control" id="valorUn" />
    <span asp-validation-for="@Model.ValorUnitario" class="text-danger"></span>
</div>

The following images show what happens when I use 3 or more digits after the comma.

When inserting 3 digits after comma

inserir a descrição da imagem aqui

When inserting 4 or more digits after the comma

inserir a descrição da imagem aqui

1 answer

1

Browser other questions tagged

You are not signed in. Login or sign up in order to post.