简体   繁体   English

使用 Javascript 在 Datepicker 中禁用以前的日期

[英]Disable Previous Dates in Datepicker with Javascript

I Am Kinda New in Javascript and I want to Disable Previous Dates from Today I used this code to display Datepicker我在 Javascript 中有点新,我想从今天禁用以前的日期我使用此代码显示 Datepicker

 <input type="text" onfocus="(this.type='date')" id="leaveTo" name="leaveTo" placeholder="DD-MM-YYYY" style="width:fit-content;">

If I got your question right, you need to make some dates to be unselectable.如果我的问题是正确的,则需要使某些日期无法选择。

That can be done by using max, min attributes.这可以通过使用 max, min 属性来完成。

For more information take a look: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/date#Additional_attributes有关更多信息,请查看: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/date#Additional_attributes

 <input type="date" min="2020-12-23">

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM