This is a migrated thread and some comments may be shown as answers.

[Solved] International Brazillian Portuguese Currency Input Validation Error

1 Answer 65 Views
NumericTextBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Maicon
Top achievements
Rank 2
Maicon asked on 16 Feb 2012, 02:39 PM
Hello all, I just started using Telerik MVC tools, and I found a problem with CurrencyTextBox I cant solve:

My Model has a field: 
...
[Required]
[Display(Name = "Valor")]
[DataType(DataType.Currency)]
public decimal Valor { get; set; }
...

And I use it in a form (razor):
...
<td>
    @Html.LabelFor(m => m.Valor)
</td>
<td>
    @Html.EditorFor(m => m.Valor)
    <span class="error">@Html.ValidationMessageFor(x => x.Valor)</span>
</td>
...

But since it is a portuguese/Brazil site, and work with Real (BRL), I changed the Currency.cshtml to:
@model decimal
 
@(Html.Telerik().CurrencyTextBox()
        .Name(ViewData.TemplateInfo.GetFullHtmlFieldName(string.Empty))
        .InputHtmlAttributes(new {style="width:100%"})
        .MinValue(0)
        .Value(Model)
        .CurrencySymbol("R$")
        .DecimalDigits(2)
        .DecimalSeparator(",")
        .NumberGroupSeparator(".")
        .Spinners(false)
)

The problem is the form format my currency ok, but always accuse the value as "not a number" since in pt_BR the comma and point are inverted R$ 10.000,00

R$ 3.671,94
 
The field Valor must be a number.



How can I solve this? I have lots of currency fields all over my forms.

1 Answer, 1 is accepted

Sort by
0
Maicon
Top achievements
Rank 2
answered on 28 Feb 2012, 01:25 PM
Tags
NumericTextBox
Asked by
Maicon
Top achievements
Rank 2
Answers by
Maicon
Top achievements
Rank 2
Share this question
or