I have a problem with the comparison of my go dates with the return date. Since this morning I have tried several things but nothing works. I would like to display an error message if the person selects the same date as the return. But this doesn't work. Who can tell me what's wrong with my code? thanks in advance :)
<template>
<div >
<datepicker v-model="dateSelectAller" lang="fr" type="date" format="dd-MM-YYYY" :lowerLimit="Date.now()" ></datepicker>
</div>
<div v-show="!isSuccess">
<span class="error-text" v-if="errors.timeAllerErrors"></span>
</div>
<div >
<datepicker v-model="dateAnterieurRetour" lang="fr" type="date" format="dd-MM-YYYY" :lowerLimit="Date.now()"></datepicker>
</div>
<div v-show="!isSuccess">
<span class="error-text" v-if="errors.dateRetour"></span>
</div>
</template>
<script>
data(){
return{
format,
dateSelectAller:new Date(),
dateAnterieurRetour: new Date(),
}
}
beforeMount(){
this.dateAnterieurRetour = this.dateAnterieurRetour.setDate(this.dateAnterieurRetour.getDate() +1)
},
watch:{
dateSelectAller(newValue){
if(newValue >= this.dateAnterieurRetour){
this.errors['dateAller'] = 'Choisir une date inférieur à celle de retour'
}else{
this.errors['dateAller'] = ''
}
console.log(newValue)
if(this.date1 === this.date2){
return this.error['timeRetourErrors'] = 'test erreur'
}else{
return this.error['timeRetourErrors'] = ''
}
},
dateAnterieurRetour(newValue){
console.log(newValue)
if(newValue <= this.dateSelectAller){
this.errors['dateRetour'] = 'la date choisi n\' est pas valide!'
}else{
this.errors['dateRetour'] = ''
}
console.log(newValue)
},
},
methods:{
getFormat () {
return this.format(new Date(this.dateSelectAller) , 'dd-MM-yyyy', {locale: window.locale})
} ,
getFormatRetour () {
return this.format(new Date(this.dateAnterieurRetour) , 'dd-MM-yyyy', {locale: window.locale})
} ,
}
</script>
Aucun commentaire:
Enregistrer un commentaire