我正在开发MVC应用程序。
在应用程序中有一个移动字段。我希望允许插入数字和+、-、(,)字符。如何为此编写验证?
现在我只有下面的代码。
[StringLength(15, ErrorMessage = "Mobile can accept maximum 15 characters.")]
public string Mobile { get; set; }发布于 2012-08-28 16:10:10
使用正则表达式验证器。
[RegularExpression(@"Pattern", ErrorMessage = "Error Message")]发布于 2012-08-28 20:04:19
就像这样
^[\+\-\(\)0-9]{10,15}$应该能行得通。
将该模式与RegularExpression属性一起使用
问候
是的
https://stackoverflow.com/questions/12155091
复制相似问题