小编ElH*_*hin的帖子

所需日期时间(+ 18年)

我有一点问题,这是我的代码:

public partial class Tourist
    {

        public Tourist()
        {
            Reserve = new HashSet<Reserve>();
        }
        public int touristID { get; set; }

        [Required]
        [StringLength(50)]
        public string touristNAME { get; set; }

        public DateTime touristBIRTHDAY { get; set; }

        [Required]
        [StringLength(50)]
        public string touristEMAIL { get; set; }

        public int touristPHONE { get; set; }

        public virtual ICollection<Reserve> Reserve { get; set; }
    }
}
Run Code Online (Sandbox Code Playgroud)

我如何限制touristBIRTHDAY为+18岁?我想我必须使用这个函数,但我不知道把它放在哪里:注意:这个函数就是一个例子.

DateTime bday = DateTime.Parse(dob_main.Text);
DateTime today = DateTime.Today;
int age = today.Year - bday.Year;
if(age < …
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc datetime required

1
推荐指数
1
解决办法
965
查看次数

标签 统计

asp.net-mvc ×1

datetime ×1

required ×1