0

我正在开发 MVC 应用程序。

在应用程序中有一个移动领域。我想允许插入数字和 +,-,(,) 字符。如何为此编写验证?

现在我只有下面的代码。

   [StringLength(15, ErrorMessage = "Mobile can accept maximum 15 characters.")]
   public string Mobile { get; set; }
4

2 回答 2

0

就像是

^[\+\-\(\)0-9]{10,15}$

应该做的伎俩。

将该模式与正则表达式属性一起使用

问候

于 2012-08-28T12:04:18.590 回答
0

使用正则表达式验证器。

[RegularExpression(@"Pattern", ErrorMessage = "Error Message")]
于 2012-08-28T08:10:09.523 回答