Replies: 9 comments
-
Is there a way to do this? |
Beta Was this translation helpful? Give feedback.
-
On |
Beta Was this translation helpful? Give feedback.
-
@Gwen42 |
Beta Was this translation helpful? Give feedback.
-
at main js file : on calling : parseDateFromInput is custom fuction like new Date(); |
Beta Was this translation helpful? Give feedback.
-
I think this might also fix the selection of the current date in the picker when the associated input has a date value in it prior to datepicker initialization. |
Beta Was this translation helpful? Give feedback.
-
Any solutions in this way? |
Beta Was this translation helpful? Give feedback.
-
@DuudeXX8 I made something custom for our company with the help of momentjs You may need to add some more conversions to momentjs format, these are the only ones we use PS. this is for
You can also add something similar to the blur event to remove invalid values
|
Beta Was this translation helpful? Give feedback.
-
You can try the following: it allows me to edit the date in the input field and reflect changes in the Air Datepicker. Using Alpine JS. ...
<div x-data="{init(){initDatepicker(this.$refs.picker, d);}}">
<input type="text" x-model="d.open_date" x-ref="picker" :id="$id('picker')">
</div> ...
initDatepicker(picker, d){
let ap = new AirDatepicker(picker,{
selectedDates: [d.open_date || new Date() ],
onSelect(date) {
d.open_date = date.formattedDate;
},
});
ap.$el.addEventListener('input', (e ) => {
try{
let currDate = ap.formatDate(ap.selectedDates[0], 'yyyy-mm-dd');
let regEx = /^\d{4}-\d{2}-\d{2}$/;
if(e.target.value.match(regEx) && currDate != e.target.value){
// set the date
ap.selectDate(e.target.value);
// open datepicker
ap.show();
// close datepicker in 1sec
setTimeout(() => {
ap.hide();
}, 1000);
}
}catch(err){
console.log(err)
}
});
} |
Beta Was this translation helpful? Give feedback.
-
I found a workaround while submitting an issue on #589 (comment) let localDate = new Date(input)
localDate.setDate(localDate.getUTCDate())
datepicker.selectDate(localDate) it allows the datepicker to properly format the user input, as long it's valid. |
Beta Was this translation helpful? Give feedback.
-
When changing date in input it should update the date in calendar, e.g. like this example here: http://eternicode.github.io/bootstrap-datepicker/
Beta Was this translation helpful? Give feedback.
All reactions