how to set the value of the current flatpickr input field using onChange?

Viewed 2917

i have several input fields initialized as flatpickr inoout fields using a class in a single page and im trying to set the current value of the each input field onChnage (selecting the date) with the dateStr value but after few tries i got no luck. any idea how to do it? here is the code im using:

flatpickr.localize(flatpickr.l10ns.fa);
flatpickr.l10ns.default.firstDayOfWeek = 6;
flatpickr(".datePicker", {
        onChange: function(selectedDates, dateStr, instance) {
            this.value = dateStr;
        },
});
1 Answers

apparently, there is no need for extra code and I just had to add the altInput: true to the options for it to work. the document was not clear about this at all.

Related