Muhammad Asim Khan
Muhammad Asim Khan

Reputation: 109

Jquery to get an instance and write it to input field

<div class="form-group">
   <div class='input-group' id='datepicker-start'>
      <input type='text' class="form-control" id='start' />
        <span class="input-group-addon date"><span class="glyphicon glyphicon-calendar"></span>
                        </span>
   </div>
</div>

Hi Guys this my date picker css with bootstrap I am using Zebra Date Picker but using bootstrap icon instead of Zebra icon which is red and i don't like it

Following is my date picking Jquery

$(document).ready(function() {
        $('#datepicker-start').Zebra_DatePicker({
         onSelect: function () {
            $zdp = $('#datepicker-start').data('Zebra_DatePicker');
            $('#start').val(zdp);
        },
            direction: true,
        });
});

What I am trying to do is copy entered date into $zdp and set it to the value of input tag whose id is start. I am new to javascript and jquery kindly guide what I am doing wrong casue this code is not running

Upvotes: 0

Views: 98

Answers (1)

Arun P Johny
Arun P Johny

Reputation: 388406

I think, you need to use the onSelect handler like

$(document).ready(function () {
    $('#datepicker-start').Zebra_DatePicker({
        onSelect: function (str1, str2, date, $el) {
            $('#start').val(str1);
        },
        direction: true,
    });
});

Upvotes: 1

Related Questions