c# - Why when I use RegularExpression as DataAnnotation is not recognizing the leading zeros? -


i have field in entity have regularexpression dataannotation:

@"^\$?([0-9]{6})(.[0-9]){0,1}?$" 

and works fine, except when use zeros before number.

ex.

- 123456.1    work - 012345.1    not work 

if same validation regex.ismatch says ok.

how can force mvc keep leading zeroes when validation?

at end used string variable , worked:

^\$?([0-9]{6})(\.[0-9])?$

  • i followed @sinsedrix , @michelle advice

Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -