[Required(ErrorMessage = "Please Enter AccountZip Code!")]
[RegularExpression(@"/(^\d{5}(-\d{4})?$/", ErrorMessage = " Zip code must be 5 characters length")]
public string AccountZip { get; set; }
I did regularexpression for Zip code validation I am getting this Error 开发者_运维问答Message
parsing "/(^\d{5}(-\d{4})?$/" - Not enough )'s.
Can any body help me out?
Thanks
Your regex looks like it was pulled from a javascript sample. Try this:
@"^\d{5}(-\d{4})?$"
You need one more ( at the end as follows:
RegularExpression(@"/(^\d{5}(-\d{4})?)$/"
Great job @"\b(0?[0-9][0-9][0-9][0-9][0-9])\b" actually works and validates both numeric and length
精彩评论