0

如何限制用户输入未来日期?

这是视图:

@Html.TextBoxFor(a => a.ARRIVING_DT,new { @class="date"})

$(".date").datepicker({   
    changeMonth: true,   
     changeYear: true,   
     dateFormat: 'dd/mm/yy' ,
     selectOtherMonths: true,
        showOtherMonths: true,
        showStatus: true,
        showButtonPanel: true,
        showOn: 'button',
        buttonImage: '../../Content/themes/base/images/i_cal.gif',
        buttonImageOnly: true,
        buttonText: 'Choose a Date'
          }); 

我正在尝试为此编写 valdation 属性:

    [Required(ErrorMessage = "Enter Date of Departure")]
    public object DEPARTURE_DT { get; set; } 

还需要写什么?Range 属性也不起作用。感谢您提供任何帮助。

4

2 回答 2

1

要禁用未来日期,请添加:

maxDate: new Date,
于 2012-05-09T10:58:56.703 回答
1
$('#<%= txtDate.ClientID  %>').datepicker({
                 maxDate: new Date(currentYear, currentMonth, currentDate)
             });
This will disable the future dates from getting entered. another best way for the question.
于 2012-05-10T13:45:39.643 回答