I'm having problems validating my fields of type decimal
using Razor, when I try to enter 0 in the field it gives the following error message.
The field XXXX must be a number.
Below is my class and how I enter the field with Razor
public class ClasseViewModel
{
[Required(ErrorMessage = "Campo Obrigatorio")]
[Display(Name = "Campo Decimal")]
public decimal? CampoDecimal { get; set; }
}
Razor:
@Html.LabelFor(model => model.CampoDecimal, htmlAttributes: new { @class = "control-label" })
@Html.EditorFor(model => model.CampoDecimal, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.CampoDecimal, "", new { @class = "text-danger" })
How would you make the validation of whether the field is numeric or would not accept the value 0.