I have this Model
public class SalesModelView
{
[Key]
public int SaleId { get; set; }
public int ShopId { get; set; }
public string ShopName { get; set; }
[Display(Name = "Date")]
public DateTime SaleDate { get; set; }
[Required]
[Display(Name = "Timer")]
[Range(0, 24)]
public int Hours { get; set; }
[Required]
[Display(Name = "Salg")]
public Decimal Sales { get; set; }
[Required]
[Display(Name = "Behandlinger")]
public Decimal Treatments { get; set; }
[Display(Name = "Omsætning")]
public Decimal Turnover { get; set; }
[Display(Name = "Oms./Timer")]
public Decimal TurnoverHour { get; set; }
[Display(Name = "Effektivitet")]
public Decimal Efficiency { get; set; }
}
and in Danish locale a decimal normally shows as 280.800,00, so . as thousands and ,as decimal place.
My view shows the correct stuff

But when saving back to my model, I get the . as a decimal separator, passing all the values to:

(original image for better visualization)
So the number 546.400 is converted to 546,4
I already tried with no luck to hook up the form submit and replace all . with nothing, like
$("form").bind("submit", function() {
$(".number").each(function(){
var v = $(this).val(v).replace('.','');
$(this).val(v);
});
});
What technique do you guys use for this kinda things?
P.S. I did read Hanselman’s article but I still got the exact same problems, it’s when I pass it to the Controller that goes wrong, all is well in the View
The DefaultModelBinder doesn’t work well in these situations. You could write your own or make sure to submit en-US values. Here is an article talking about it.
Model Binding Decimal Values