0

I'm using vee-validate for validation purpose

<datetime v-validate="'required'" format="YYYY-MM-DD H:i:s" name="futureDates" width="100px" :class="['form-control', {'is-invalid': errors.has('futureDates')}]" v-model="formfutureDates" ></datetime> 

 <datetime v-validate="'required'" format="YYYY-MM-DD H:i:s" name="prevDates" width="100px" :class="['form-control', {'is-invalid': errors.has('prevDates')}]" v-model="prevDates" ></datetime>

Now trying to validate future date and previous dates in futureDates field if user enters previous dates then it should validate and show error and in previous Dates if user enters future dates then it should validate and show error message.

Any help is highly appreciated.

user3653474
  • 3,393
  • 6
  • 49
  • 135

1 Answers1

0

probably you can watch the prevDates, then set up their props min and max. Just like the following lines:

<datetime :min="prevDates" v-validate="'required'" format="YYYY-MM-DD H:i:s" name="futureDates" width="100px" :class="['form-control', {'is-invalid': errors.has('futureDates')}]" v-model="formfutureDates" ></datetime> 

 <datetime v-validate="'required'" format="YYYY-MM-DD H:i:s" name="prevDates" width="100px" :class="['form-control', {'is-invalid': errors.has('prevDates')}]" v-model="prevDates" ></datetime>

I just give a thinking, I haven't used the component like this.

Or make another sight of it, you can set the max for the prevdates is the formfutureDates

Dharman
  • 30,962
  • 25
  • 85
  • 135
newbie
  • 66
  • 2
  • @Dharman : Thanks for the answer, i was trying to validate datetime using vee-validate only as shown in this link : https://stackoverflow.com/questions/50881323/vee-validate-custom-date-validation, but having issue suppose if i enter datetime in the field it is still showing the datetime field is required. – user3653474 May 23 '21 at 15:07