ASP.NET MVC 3 - Client Validation with a Money Field

I made this blog here and here .

And I have the following problem.

One field in my form is the currecy format, from Brazilian. I use client side validation. Everything works fine, one problem.

I have 2 checks:

[DisplayName("Taxa de adesão")]
[MoedaReal(ErrorMessage = "Taxa deve ser numérico")]        
[Required(ErrorMessage = "Taxa é obrigatório")]
public decimal ValorAdesao { get; set; }

The REQUIRED rule works fine, the MoedaReal rule works fine. After these rules are passed normally, one last rule is launched:

  • Taxa de adesão field must be a number

I already tried changing the web.config file in this line:

<globalization culture="pt-br" uiCulture="pt-br" />

Number format is welcome:

1,00
11,00
111,00
1.111,00
11.111,00
111.111,00
1.111.111,00
1.111.111.111.111,00

How can I “trick” .NET to accept this format? Because he expects the DECIMAL format.

+3
source share
1

. , , web.config. , , . , en-US pt-BR, . :

<globalization culture="auto" uiCulture="auto" />

, , , . , :

  • ,
+2

Source: https://habr.com/ru/post/1789817/


All Articles