0

I am using element ui datepicker from there. I want to disable past dates.

<el-date-picker
  v-model="form.startDate"
  type="date"
  placeholder="Tarih Seçiniz."
  style="width: 100%"
/>

Can you help me to handle this issue?

1 Answer 1

1

You can achieve this by adding a :disabled-date attribute in the <el-date-picker> element and pass the boolean value to this attribute based on the calculation.

<el-date-picker :disabled-date="disabledDate" ...

In Script:

const disabledDate = (time: Date) => {
  const date = new Date();
  const previousDate = date.setDate(date.getDate() - 1);
  return time.getTime() < previousDate; 
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.