flatpickr
flatpickr copied to clipboard
DefaultDate not working
I cannot set the default date of an input field. I am building a laravel app and if I enter a date and the validation fails, I want to persist the data that was entered. This works fine for all fields besides the date. Here is the issue in a jsfiddle https://jsfiddle.net/sj6gryd1/
Is this the proper way to preload a date?
You can do like this https://jsfiddle.net/sj6gryd1/2/
you need to use or value="..." in HTML or defaultDate: "..." in JS. But don't forget about format date!
<article>
<input type="text"
placeholder="Select Date.."
class="date"
value="06-28-1987"
>
</article>
const fp = flatpickr(".date",{
dateFormat: "m-d-Y"
// ,defaultDate: "06-28-1987"
});
@JuanRangel looks like you forgot to specify your dateFormat
See @MaximSavin response