0

私は MVC アプリケーションを開発しており、フォームで datepicker を使用しています。フォームで以下のコードを使用しています。

  $(document).ready(function () {


        $(function () {
            $('.BirthDate').datepicker({
                dateFormat: "dd-M-y",
                yearRange:'1930:1995',
                buttonImage: '@Url.Content("~/Resource/Calender.jpg")',
                buttonImageOnly: true
            });
        });

        $(".BirthDate" ).datepicker( "setDate", "01/01/1995" );
      });

ユーザーが将来の日付を選択できるようにしたくありません。年の範囲を使用しましたが、2013 年の将来の月を選択できます。どのプロパティを使用する必要がありますか?

4

1 に答える 1

5

maxDateオプションhttp://api.jqueryui.com/datepicker/#option-maxDateを使用します

$(function () {
         $('.pickDate').datepicker({
             dateFormat: "dd-M-y",
             yearRange:'2011:2013',
             maxDate: 0,
             defaultDate: '01-01-2013'
         });

     });

Op の最近の変更に関して、改訂されたコードは次のとおりです。

    $(function () {
        $('.BirthDate').datepicker({
            dateFormat: "dd-M-y",
            yearRange:'1930:1995',
            buttonImage: '@Url.Content("~/Resource/Calender.jpg")',
            buttonImageOnly: true,
            maxDate:0
        });
    });

    $(".BirthDate" ).datepicker( "setDate", "01-01-1995" );
于 2013-05-08T07:23:06.123 に答える