Alex303's avatar

Get date onChange Tailwind CSS Datepicker Flowbite

https://flowbite.com/docs/plugins/datepicker/#inline-datepicker

I'm using the Inline datepicker from Flowbite, have made it work but I can not find in the documentation how to get the date on change, any idea?

0 likes
2 replies
sirodas1's avatar

Hi have you been able to find a solution to this?

henrik561's avatar

I found a solution that worked for me, by changing the type to "date" instead of "text" i was able to listen for the event change date:

<input ref="datepickerInput" v-model="picker.date" @changedate="handleDateChange" id="datepicker-format"
                datepicker datepicker-format="mm-dd-yyyy" type="date"
                class="border-gray-300 w-full focus:border-indigo-500 focus:ring-indigo-500 ps-10 rounded-md shadow-sm"
                placeholder="Select date" />

As u can see in my case i was able to use @changedate (i use vue3) and call a function.

It is also possible via javascript:

datepickerElement.addEventListener('changeDate', (e) => {
  console.log(e.target.value);
});

// or jQuery
$('#datepicker').on('changeDate', function(){
  console.log(e.target.value);
});

I hope this helps!

Please or to participate in this conversation.