jquery datepicker dynamic with personal format
I'd want to applhy at dynamic element datepicker with a custom format. I
have tried this but doesn't work, no error in console:
var arr_month = new Array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
$( "#check-out").datepicker({
dateFormat: 'dd/M/yy',
monthNamesShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
});
$(document).on('focus',".date-input", function(e){
e.preventDefault();
var myDate = new Date(new Date().getTime() + 48 * 60 * 60 * 1000);
var prettyDate =(myDate.getDate()) + '/' + (myDate.getMonth()+1);
var formattedDate = $.datepicker.formatDate('dd-M', myDate,
{monthNamesShort: arr_month});
$(this).val(formattedDate);
});
Ii I put only works fine! :
$(document).on('focus',".date-input", function(e){
e.preventDefault();
$(this).datepicker();
});
The code is inside document.ready
How can I apply custom format to dynamic element to datepicker?
No comments:
Post a Comment