asp.netregexvalidationrangevalidator

asp.net textbox double (0,00) value validation


I have a problem about validation controls. I have a textbox and I want to get amount value from this control. I use RegularExpressionValidator with this regex

^(\d+([\,]\d*)?)|(\d*([\,]\d+))$

and also I add requiredfieldvalidator. It is ok but I need one more control because I set the default text value 0,00 and I don't want to be able to pass with 0,00 it must be >0,00.

What can I do?

RangeValidator is useless in this situation because 0,00-x,xx not acceptable for me. Please help.


Solution

  • Something like this should do

    ^(?!0+(,0+)?$)((\d*,)?\d+)$
    

    If you want only 2 digits after ,, you can do this

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