C#- Validation for US or Canadian zip code

前端 未结 3 741
旧时难觅i
旧时难觅i 2020-12-14 18:11

I am using following method to validate US or Canadian zip code, but i think it is not working fine for me. Please suggest me the changes in the regular expression.

3条回答
  •  独厮守ぢ
    2020-12-14 18:33

    The US zipcode validation which works "on my machine" is

    [RegularExpression(@"\d{5}$", ErrorMessage = "Invalid Zip Code")]
    

提交回复
热议问题