First of all, I'm noob :)
I'm trying to replace a CodeIgniter application DateTimePicker with another library called "Persian Datepicker" (https://babakhani.github.io/PersianWebToolkit/doc/datepicker).
1. On the first try, I tried altField option:
I created another input with "Persian Datepicker" that filled the original value automatically with the converted format (using Jalali Moment). Everything works fine, Original input value format is correct, but somehow the value didn't save at all; It works Only when the original input is modified by the user.
$('#duedate.jdatepicker').persianDatepicker({
format: "YYYY/MM/DD",
initialValue: false,
calendarType: "persian",
observer: true,
responsive: true,
calendar: {
persian: {
locale: "en",
}
},
onSelect: function() {
var dataDue = $('#jalali_due.pdatepicker').val();
var dueConv = moment.from(dataDue, 'fa', 'YYYY/MM/DD').format('YYYY-MM-DD');
$('.altDue').val(dueConv);
}
});
- After I failed with that, I tried to completely replace the already existed DateTimePicker, with "Persian Datepicker". In this case, Jalali should be converted to Gregorian date right after the user selects it because the application only uses the Gregorian format. I couldn't do this either :( I tried the code below...
$('#startdate.jdatepicker').persianDatepicker({
format: "YYYY/MM/DD",
initialValue: false,
calendarType: "persian",
observer: true,
responsive: true,
calendar: {
persian: {
locale: "en",
}
},
onSelect: function(year) {
var self = this;
var startData = self.calendar;
if (startData = "persian") {
$('#startdate.jdatepicker').val('/**Gregorian Format**/')
} else {
$('#startdate.jdatepicker').val('/**Gregorian Format**/')
}
}
});
Please help me out with this; Also if there's a better solution, let me know.
The application uses https://xdsoft.net/jqplugins/datetimepicker/ for DateTime Picker
Regards,