flatpickr icon indicating copy to clipboard operation
flatpickr copied to clipboard

DefaultDate not working

Open JuanRangel opened this issue 9 years ago • 2 comments

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?

JuanRangel avatar Jun 22 '17 19:06 JuanRangel

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"
});

MaximSavin avatar Jun 23 '17 06:06 MaximSavin

@JuanRangel looks like you forgot to specify your dateFormat See @MaximSavin response

chmln avatar Jun 27 '17 12:06 chmln