Menu ▼



Posted By :
avatarmrkraju
Total Views : 16232

JQuery Date Picker example to disable future dates.

To disable future dates in JQuery date picker, we need to set the maxDate property.

  1. maxDate : 0 then all the future dates will be disabled


    HTML
    <input id="txtfuturedate" type="text" />
    JQuery
    $("#txtfuturedate").datepicker({
        maxDate: 0
    });

    Note: If we increase the value then it disable the dates after the given days.
    ex: if we give maxDate:5 then all the future dates after 5 days will be disabled.

  2. maxDate : '+1w' then all the future dates after a week will be disabled


    HTML
    <input id="txtfuturedateweek" type="text" />
    JQuery
    $("#txtfuturedateweek").datepicker({
        maxDate: "+1w"
    });

    If we give maxDate: '+2w' then all the future dates after 2 weeks will be disabled.

  3. maxDate : '+1m' then all the future dates after a month will be disabled


    HTML
    <input id="txtfuturedatemonth" type="text" />
    JQuery
    $("#txtfuturedatemonth").datepicker({
        maxDate: "+1m"
    });

  4. maxDate : '+1y' then all the future dates after a year will be disabled


    HTML
    <input id="txtfuturedateyear" type="text" />
    JQuery
    $("#txtfuturedateyear").datepicker({
        maxDate: "+1y"
    });





comments powered by Disqus


Search dotnetlearners.com