时间:2010-07-26 06:19:29

标签: asp.net datetime format requiredfieldvalidator

2 个答案:

答案 0 :(得分:7)

MinimumValue&需要在Page_PreRender事件中设置MaximumValue,并且似乎要求日期格式为“dd-MM-yy”...请参阅Rangevalidator Min Max Value error上的最后一篇文章

protected void Page_PreRender(object sender, EventArgs e)
{
    RangeValidator1.MinimumValue = DateTime.Now.Date.ToString("dd-MM-yy");
    RangeValidator1.MaximumValue = DateTime.Now.Date.AddYears(90).ToString("dd-MM-yy");
}

答案 1 :(得分:2)

MinimumValue和MaximumValue的格式应为yyyy / MM / dd

检查文档: https://msdn.microsoft.com/en-us/library/ydez7ad7(v=vs.110).aspx