javascript - Format datepicker date to input -
i trying make datepicker work. datepicker pops when click calendar icon right next input field. when use clicks icon, , selects date, input field should populate date. works if not try format date, do,
'cannot read property "formatdate" of undefined'
the icon of calendar has class of '.calendar'. here code when click icon.
$('.calendar').datepicker({ format: 'mm/dd/yy', startdate: '-1' }).on('changedate', function (ev) { $(this).prev('input').val( $.datepicker.formatdate('mm/dd/y', ev.date) ); $(this).datepicker('hide'); });
as hits
$(this).prev('input').val( $.datepicker.formatdate('mm/dd/y', ev.date) );
it stops working. doing wrong here?
if $(this).prev('input').val(ev.date);
works perfect, format wrong, , not go database.
thank in advance.
Comments
Post a Comment