我想显示两条不同的错误消息。首先给出Int64值的必需值和秒值。这是我的代码。
[Display(Name = "Employee")]
[Required]
public Int64 EmployeeId { get; set; }
答案 0 :(得分:1)
您可以使用RangeAttribute。
[Required(ErrorMessage = "Msg1")]
[Range(10, 1000,
ErrorMessage = "Value for {0} must be between {1} and {2}.")]
public object Weight;
答案 1 :(得分:0)
您可以在此处使用数据注释扩展:http://dataannotationsextensions.org/
然后按如下方式添加两个注释:
[Required(ErrorMessage = "Employee Id is required")]
[DataAnnotationsExtensions.Integer(ErrorMessage = "Please enter a valid number.")]
public Int64 EmployeeId { get; set; }