简体   繁体   中英

Not being able to disable dates previous from today using datepicker

I am having a jquery issue where I am trying to disable the days before today using the .datepicker calendar.

I've tried using $('.datepicker').datepicker({ startDate: '0d' }).on('changeDate', function(e){$(this).datepicker('hide'); , however this does not seem to be working.

The question is now: Why is it not working and how can I make it?

Here is my code that I am trying to implement it in:

<label for="payment">First payment date* </label>
      <div class="input-group amount">
        <input data-format="date" type="text" name="FirstPayDate" placeholder="First payment date*" class="datepicker form-control" 
        onsubmit="return validateForm()"id="firstPayDate" value="%%=v(@firstPayDate)=%%" required>

EDIT: I've edited the code given to show the original line of code where I am trying to implement the startDate.

Set the minDate value to 0.

$('.datepicker').datepicker({ minDate: 0 });

Source: https://jqueryui.com/datepicker/#min-max

Try to use startDate . Checkout: https://jsfiddle.net/s1ytztux/

$('.datepicker').datepicker({
 startDate: '0d'
});

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