1
votes

I have a field that requires the user to select year only from a datepicker.

enter image description here

The picture above displays it correctly. But when I cloned the fields the year picker now displays the datepicker which displays the day, month and year format. Like this:

enter image description here

How can I set it back in displaying the year picker in the cloned fields? This is my jquery for cloning the fields.

   $(document).ready(function() {

     var newRow = $("#collegeField").clone();

     $('.yrpicker').datepicker

     $("#collegebtn").on("click", function() {

       newRow.clone().appendTo("#collegeField").find(".yrpicker").datepicker();
     });

   });

<div class="form-group col-md-1">
<label for="college_school">Started</label>
    <input type="text" class="form-control datepicker yrpicker" name="yrStarted" id="yrStarted" placeholder="From">
</div>

<div class="form-group col-md-1">
<label for="college_school">Graduated</label>
    <input type="text" class="form-control datepicker yrpicker" name="yrGrad" id="yrStop" placeholder="To">
</div>
1

1 Answers

0
votes

This is your solution.

$("#datepicker").datepicker({
    changeMonth: false,
    changeYear: true
});