简体   繁体   中英

dynamic mindate based on data-attribute for jquery datepicker

I have an input element

<input id="order_neediton" class="form-control hasDatepicker" type="date" name="order[neediton]" data-notice="3">

and the jquery datepicker like so

$(function() {
    $("#order_neediton").datepicker({ constrainInput: false , maxDate: "+1m", minDate: "{$('#order_neediton').attr('data-notice')}d"});
  });

so as to have the miniumum date start 3 days from today.

But it does not work, how should I go about doing it?

Try with this

$(function () {
    var min = $('#order_neediton').attr('data-notice');
    $("#order_neediton").datepicker({
        constrainInput: false,
        maxDate: "+1m",
        minDate: min + "d"
    });
});

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