error with decimal in mvc3 - the value is not valid for field

后端 未结 9 1642
北荒
北荒 2020-11-29 08:03

I\'m following [Getting started with ASP.NET MVC 3][1]. And I can\'t add/edit with value of Price = 9.99 or 9,99. It said: \"The value \'9.99\' is not valid for Price.\" and

9条回答
  •  囚心锁ツ
    2020-11-29 08:47

    I solved this problem by disabled jquery for price and only validate on server side for that input. I found the answer here: ASP .NET MVC Disable Client Side Validation at Per-Field Level

    @{ Html.EnableClientValidation(false); } @Html.EditorFor(model => model.DecimalValue, new { htmlAttributes = new { @class = "form-control" } }) @{ Html.EnableClientValidation(true); } @Html.ValidationMessageFor(model => model.DecimalValue, "", new { @class = "text-danger" })

提交回复
热议问题