In Model , use this:
[Required]
[DataType(DataType.Currency)]
[Display(Name = "Price", ResourceType = typeof(Resources.Language))]
public Decimal Price { get; set; }
In Views , use the NuGet JQuery Masked Input package , then it is I need to add a @section scripts
to your View:
@section scripts {
<script type="text/javascript">
$(function() {
$('#Price').maskMoney({ prefix: 'R$ ', allowNegative: false, thousands: '.', decimal: ',', affixesStay: false });
});
</script>
}
Incidentally, it is also good to inform Web.config
about the crop used. It's not exactly needed for this case, but it can serve the rest of the system well.
<configuration>
<system.web>
...
<globalization uiCulture="pt-BR" culture="pt-BR" enableClientBasedCulture="true" />
...
</system.web>
</configuration>