Open joelyeye opened 4 years ago
@joelyeye you can use react-datepicker library to only go back to restricted amount of years. You can try out using react moment library and u can pass props like min and max dates to restrict the year limit
<DatePicker
open={dateOpen}
minDate={moment().subtract(18, 'years').toDate()}
maxDate={moment().toDate()}
mode="date"
onConfirm={date => {
let mm = date.getMonth() + 1;
let dd = date.getDate();
const yy = date.getFullYear();
if (dd.toString().length === 1) dd = 0${dd}
;
if (mm.toString().length === 1) mm = 0${mm}
;
const selectedDate = ${dd}/${mm}/${yy}
;
setDateOpen(false);
}}
onCancel={() => {
setDateOpen(false);
}}
/>
Is there a way to restrict the calendar to only go back to n amount of years? I am having an issue that when a user enters lets say 10/15/19 it pick 10/15/0019 instead if 10/15/2019.
Thanks