Monday, 19 August 2013

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

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

pI have a field in my entity which have a RegularExpression as a
DataAnnotation:/p precode@^\$?([0-9]{6})(.[0-9]){0,1}?$ /code/pre pAnd it
always works fine, except when I use zeros before the number./p pEx./p
precode- 123456.1 Work - 012345.1 Does Not Work /code/pre pIf I do the
same validation with Regex.IsMatch it says is ok./p pHow can I force MVC
to Keep the leading zeroes when it does the validation?/p

No comments:

Post a Comment