[RegularExpression(@"/(^\(\d{10})?)$/",ErrorMessage = "Please enter proper contact details.")] [required] [Display(Name = "Contact No")] public string ContactNo { get; set; }
但验证表达式无效.
对于联系号码,我只想接受数字.它可以是10位移动电话号码或固定电话号码.
请尝试以下方法:
@"^\((\d{10}?)\)$"
或者如果你想要10个数字:
@"^(\d{10})$"