How to get the date from jQuery UI datepicker

前端 未结 6 1079
渐次进展
渐次进展 2020-11-30 01:44

I want to get the date from datepicker whenever user choose the date in jQuery UI datepicker and click the button on the form.

well I need to get the day, month and

6条回答
  •  无人及你
    2020-11-30 01:59

    Sometimes a lot of troubles with it. In attribute value of datapicker data is 28-06-2014, but datepicker is show or today or nothing. I decided it in a such way:

    
    

    I added to the input of datapicker attribute data-value, because if call jQuery(this).val() OR jQuery(this).attr('value') - nothing works. I decided init in cycle each datapicker and take its value from attribute data-value:

     $("form .datepicker").each(function() {
            var time = jQuery(this).data('value');
            time = time.split('-');
            $(this).datepicker('setDate', new Date(time[2], time[1], time[0], 0, 0, 0));
        });
    

    and it is works fine =)

提交回复
热议问题