talkhabi / vue-persian-datetime-picker

A vue plugin to select jalali date and time
https://talkhabi.github.io/vue-persian-datetime-picker/
588 stars 78 forks source link

required attribute is not working #113

Closed r-yeganeh closed 4 years ago

r-yeganeh commented 4 years ago

Hi!

How do you exactly make this lovely picker a required field? I tried the below code but it didn't work?

<jalali-picker type="datetime" format="YYYY-MM-DD HH:mm" display-format="jYYYY/jMM/jDD | YYYY-MM-DD | HH:mm" v-model="data" required> </jalali-picker>

talkhabi commented 4 years ago

Hi @r-yeganeh I strongly recommend you to use validation plugins like vee-validate

<vee-observer ref="form" tag="form" @submit.native.prevent="submit">
  <vee-provider v-slot="{ errors }" rules="required" name="birthday">
    <date-picker  v-model="form.birthday" view="year" />
    <div class="text-danger" v-text="errors[0]" />
  </vee-provider>
  <button type="submit" v-text="'SUBMIT'" />
</vee-observer>