I have a form implemented with laravel and vue2 and it has some date fields where I'm using datepicker plugin. But problem is, when I go and type in the next (or any other) input, the value of the date field(s) becomes empty. I have tried many ways and looked for many questions and none helped.
See this Short Video for better understanding of the problem
input
<div class="form-group">
<label class="col-form-label col-form-label-sm" for="memo_date">Memo Date</label>
<input v-model="form.memo_date" class="form-control demoDate2" id="memo_date" name="memo_date" type="text" placeholder="DD-MM-YYYY" autocomplete="off" value="{{old('memo_date')}}">
<span class="text-danger" v-if="errors.memo_date">@{{ errors.memo_date[0] }}</span>
</div>
<div class="form-group">
<label class="col-form-label col-form-label-sm" for="from_date">From Date</label>
<input class="form-control demoDate2" v-model="form.from_date" @keyup.prevent="getDuration" id="from_date" name="from_date" type="text" placeholder="DD-MM-YYYY" autocomplete="off">
<span class="text-danger" v-if="errors.from_date">@{{ errors.from_date[0] }}</span>
</div>
<div class="form-group">
<label class="col-form-label col-form-label-sm" for="to_date">To Date</label>
<input class="form-control demoDate2" v-model="form.to_date" @keyup.prevent="getDuration" id="to_date" name="to_date" type="text" placeholder="DD-MM-YYYY" autocomplete="off">
<span class="text-danger" v-if="errors.to_date">@{{ errors.to_date[0] }}</span>
</div>
<div class="form-group">
<label class="col-form-label" for="memo_no">Memo No</label>
<input class="form-control" v-model="form.memo_no" id="memo_no" type="text" name="memo_no" value="{{ old('memo_no') }}">
<span class="text-danger" v-if="errors.memo_no">@{{ errors.memo_no[0] }}</span>
</div>
data and mounted function
data: {
...
...
form: {
attachment:'',
memo_no:'',
memo_date:'',
from_date:'',
to_date:'',
duration:'',
description:'',
employees_ids:[],
},
errors:[]
},
mounted: function (){
// datepicker
$('.demoDate2').datepicker({
format: "dd-mm-yyyy",
autoclose: true,
todayHighlight: true,
orientation: "bottom auto"
});
}
Additional Note: I used change() event inside mounted() to alert when the date value is added using datepicker/keyboard and it fires. BUT when the value is removed, the event does not fire!
I have tried This and many more but none helped. Please help me find the issue. Any help is appreciated.