我有一个很大的问题,我在网上搜索过,我尝试了几种解决方案(changind modelbinder and culture),但没有任何对我有用的东西。 我创建了一个包含多个字段和特定字段的模型
[Display(Name = "Costo ora/allievo (max € 23,00)")
public decimal CostoAula { get; set; }
然后我创建了一个带有视图的控制器,然后我已经映射了sqlserver。
在视图中我有:
<div class="row">
<div class="form-group col-md-4">
@Html.LabelFor(model => model.CostoAula, htmlAttributes: new { @class = "control-label col-md-4" })
<div class="col-md-8">
@Html.TextBoxFor(model => model.CostoAula, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.CostoAula, "", new { @class = "text-danger" })
</div>
</div>
</div>
当我输入123,00时,它表示这不是一个数字。当我输入123.00它保存,但在数据库中我有12300因为数据库接受逗号作为小数分隔符。
所以我用这个改变了jquery.validate数字相关的行:
number: function( value, element ) {
return this.optional(element) || /^-?(?:\d+|\d{1,3}(?:\.\d{3})+)(?:[,]\d+)?$/.test(value);
},
但它不起作用。它每次都给我同样的错误!
请帮帮我! 提前谢谢!