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

java - How to Configure JAXRS and Spring With Annotations -

visual studio - TFS will not accept changes I've made to a Java project -

php - Create image in codeigniter on the fly -