任何正文都可以告诉我如何使用正则表达式检查空字符串
[RegularExpression(@"\b(0?[0-9][0-9][0-9])\b", ErrorMessage = "BEI Code should be Only three Chracter Length!")]
我还需要在此验证中查找空字符串
感谢
答案 0 :(得分:2)
为什么不使用Required
属性旁边的RegularExpression
验证属性检查空字符串?
[Required(ErrorMessage = "This field is required")]
[RegularExpression(@"\b(0?[0-9][0-9][0-9])\b",
ErrorMessage = "BEI Code should be Only three Chracter Length!")]