In my application I have a form where a user can create a new part.
The form for creating the part contains basic things like ID, Name, Description etc. However I am having some trouble with the Price
field.
The Price
field is set to a decimal:
[Table("pricelist")]
public class Pricelist
{
[Key]
[Required]
public int Price_id { get; set; }
public string CategoryId { get; set; }
public string SubCategoryId { get; set; }
public string AdminDescription { get; set; }
public string AdminDescriptionShort { get; set; }
public string Standard { get; set; }
public string Unit { get; set; }
public decimal? Quantity { get; set; }
public decimal Price { get; set; }
But when I type in a value like 50,12, it gives me a ValidationMessage that sais: "The field Price must be a number."
It does not give me an Error however.
Here is the form field:
<div class="form-group">
@Html.Label("Prijs", htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Price, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Price, "", new { @class = "text-danger" })
</div>
</div>
What I find weird is that it does work in another form.
Other form:
<div class="form-group">
@Html.Label("Prijs", htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Price, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Price, "", new { @class = "text-danger" })
</div>
</div>
I have tried setting it to a float before but that did not work out. I don't think the Error from this attempt to fix it matters since I found out that what goes wrong in one form, works in the other form.