首页 > 解决方案 > 最大年龄的数据注释大于最小年龄

问题描述

如何验证最大年龄应大于 mvc dot net 中数据注释中的最小年龄?

当用户输入表单时,我想使用 MVC dot net 中的数据注释来验证最大年龄是否大于最小年龄

In my case , 

public class ModelForm 
{
    [Required]
    [Range(10,70,ErrorMesaage = "Enter the minimum age between 10 to 70 !" )] 
    public int MinAge {get;set;}


    [Required]
    [Compare("//Entered MinAge" , 80 , ErrorMessage = "Maximum Age Should be Greater than Minimum Age !" )]
    public int MaxAge {get;set;}
}

标签: .netvalidationmodel-view-controllerdata-annotations

解决方案


推荐阅读