i've a great problem, i've searched around the web and i have tried several solution (changind modelbinder and culture) but nothing working for me. I have created a model with several fields and this specific field
[Display(Name = "Costo ora/allievo (max € 23,00)")
public decimal CostoAula { get; set; }
Then i have created a controller with views then i have mapped sqlserver.
in the view i have:
<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>
When I enter 123,00 it says that is not a number. When I enter 123.00 it saves, but in the database I have 12300 because database accept comma as decimal separator.
So i have changed jquery.validate number related row with this:
number: function( value, element ) {
return this.optional(element) || /^-?(?:\d+|\d{1,3}(?:\.\d{3})+)(?:[,]\d+)?$/.test(value);
},
But it doesn't work. It give me everytime same error!
Please help me! Thank you in advance!