Disable all days except any two date in a month bootstrap date picker

68 views Asked by At

Dev,

I have requirements such as "Need to disable all the dates except 1st & 16th date every month".

My customer doesn't want to select the rest of the dates at any time. I have tried to achieve that in a lot of ways but I was not able to find a solution.

Here, While I google everyone suggested to use "beforeShowDay" and check the date as 1 & 16 then return true. But I don't want to go by that solution. Because my application datetimepicker() uses common code.

So I want to achieve the solution by using data attributes. Like "data-date-days-of-week-disabled="[0,6]" I have disabled Saturday & Sunday by using this method.

Could anyone help me write data attribute logic for my scenario?

I tried, data-date-days-disabled=[2,3,4,5,6] up to 30 except 1 & 16. But it's not working.

enter image description here

Here I have disabled the Saturday & Sunday by using data-date-days-of-week-disabled="[0,6]"

Like wise I want to disable the date 2 to 15 and 16 to 30 / 31. Meaning I want to enable 1st date & 16th date of each month.

<div class="col-12 col-sm-3 col-md-3 col-lg-3">
<div class="input-group date datetimepicker revenueStartDate" data-min-view="2" data-date-format="mm-dd-yyyy"  data-date-days-of-week-disabled="[0,6]"   >
    <input class="form-control form-control-sm" size="16" type="text" id="fromDate" name="fromDate" value="#dateformat(now(),'mm-dd-yyyy')#">
    <div class="input-group-append"> 
        <button class="btn btn-primary"><i class="icon-th mdi mdi-calendar"></i></button>
    </div>
</div>
0

There are 0 answers