1

On add more click i am generating multiple date picker but its not working please help me code is bellow

Html Code

<input type="text" name="end_date[]" class="form-control pull-right" id="datepicker" required>  
<input type="text" name="start_date[]" class="form-control pull-right" id="datepicker1" required>

javascript code

$(function () { $("#datepicker").datepicker( {format: 'yyyy-mm-dd'}); });
$(function () { $("#datepicker1").datepicker({format: 'yyyy-mm-dd'}); });
Code Lღver
  • 15,573
  • 16
  • 56
  • 75

1 Answers1

0

As you have mention that you are creating dynamic text field so you have to use .on function:

Here is the solution:

$(function (){
   $('body').on('focus',"#datepicker", function(){
       $(this).datepicker({format: 'yyyy-mm-dd'});
   });​
   $('body').on('focus',"#datepicker1", function(){
       $(this).datepicker({format: 'yyyy-mm-dd'});
   });​
});

Feel free to ask if you have any query.

Code Lღver
  • 15,573
  • 16
  • 56
  • 75