-1

I am using jQuery-1.12.4 for my datepicker in Laravel-5.8

<input type="text" id="holiday_date" class="form-control" name="holiday_date" value="{{old('holiday_date')}}" >

<script type="text/javascript">
    $(document).ready(function() {
            $('#holiday_date').datepicker({
                dateFormat: 'yy-mm-dd',

    });
</script>

How to I limit the JQuery datepicker to :

  1. first day of the current year

  2. last day of the current year

Watercayman
  • 7,970
  • 10
  • 31
  • 49
mikefolu
  • 1,203
  • 6
  • 24
  • 57
  • Does this answer your question? [How to manipulate commencement date and resumption date using JQuery Date in Laravel](https://stackoverflow.com/questions/62885289/how-to-manipulate-commencement-date-and-resumption-date-using-jquery-date-in-lar) – Don't Panic Jul 13 '20 at 23:50
  • Please don't ask duplicate questions. – Don't Panic Jul 13 '20 at 23:50

1 Answers1

0

There is a function called yearRange that will do this for a specific year, but if you want it to be dynamic, you can use maxDate and minDate. Remember, the year starts at month 0 and ends at month 11:

 $(document).ready(function() {
       $('#holiday_date').datepicker({
            minDate: new Date(year, 0, 1),
            maxDate: new Date(year, 11, 31)
       }
 }
Watercayman
  • 7,970
  • 10
  • 31
  • 49