简体   繁体   中英

How to select date in jquery datepicker based on another jquery datepicker

Here is my code:

<script type="text/javascript">
            $(function () {
                $("#datepicker1").datepicker({ maxDate: new Date });
            });
            $(function () {
                $("#datepicker2").datepicker({ maxDate: new Date });
            });


        </script>

if i select date(example: 12-08-2013) in #datepicker1 , i need to select date in #datepicker2 on or after date(example: 12-08-2013).

Try

$(function () {
    $("#datepicker1").datepicker({
        maxDate: new Date,
        onSelect: function(date){
            $("#datepicker2").datepicker('option', 'minDate', date);
        }
    })
});
$(function () {
    $("#datepicker2").datepicker({
        maxDate: new Date
    });
});

Demo: Fiddle

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM