简体   繁体   中英

how to exclude previous date from date picker

this is the javascript code. on the borrow date, it will show the previous date from today. how to diselect previous date from it?

        $("#date_borrow").datepicker({
            showAnim: 'drop',
            numberOfMonth: 1,
            dateFormat: 'dd-mm-yy',
            onClose: function (selectedDate) {
                $("#date_return").datepicker("option", "minDate", dateToday);
            }
        });



        $("#date_return").datepicker({
            showAnim: 'drop',
            numberOfMonth: 1,
            dateFormat: 'dd-mm-yy',
            onClose: function (selectedDate) {
                $("#date_borrow").datepicker("option", "maxDate", selectedDate);
            }

        });

    });

You can add:

var dateToday = new Date();

and inside:

.datepicker({
...
minDate: dateToday,

In datepicker 1.9.0 from: https://uxsolutions.github.io/bootstrap-datepicker

startDate: new Date(),
var dateToday = new Date();
        $("#date_borrow").datepicker({
            showAnim: 'drop',
            numberOfMonth: 1,
            dateFormat: 'dd-mm-yy',
            onClose: function (selectedDate) {
                $("#date_return").datepicker("option", "minDate", selectedDate);
            }
        });



        $("#date_return").datepicker({
            showAnim: 'drop',
            numberOfMonth: 1,
            dateFormat: 'dd-mm-yy',
            onClose: function (selectedDate) {
                $("#date_borrow").datepicker("option", "minDate", dateToday);
            }

        });

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