RegularExpression allow greater than 0.00

0

False value:

0,00 -- false

True value:

0,01 -- true
0,10 -- true
1,00 -- true
10,00 -- true
100,00 - true
1.000,00 -- true
10.000,00 -- true
100.000,00 --true
1.000.000,00 -- true
10.000.000,00 -- true
100.000.000,00 -- true
1.000.000.000,00 -- true

That is, it can only be greater than 0.00.

Follow the code:

[RegularExpression(@"^(?!0,00)\d+\,\d{0,2}$", ErrorMessage = "Inválido")]

The problem is 1,000.00

Any solution?

    
asked by anonymous 07.03.2017 / 21:07

2 answers

1

Just change your code:

Exchange:

^(?!0,00)\d+\,\d{0,2}$

By:

^(?!0,00)\s*(?:[1-9]\d{0,2}(?:\.\d{3})*|0)(?:,\d{1,2})?$

Follow regex online:

link

    
07.03.2017 / 21:34
1

Solution

^(?!^(0{1,3}\.?)+(,00)?$)(\d{1,3}\.?)+(,\d\d?)?

Running on REGEX101

    
08.03.2017 / 19:18