如何禁止选择相同的日期以在rangepicker antd中选择同一日期?
我希望用户无法为开始和结束选择同一日期。例如,如果用户选择开始日期为30/06/2022,则他只能选择01/07/2022或更多。在API中找不到任何东西
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
我希望用户无法为开始和结束选择同一日期。例如,如果用户选择开始日期为30/06/2022,则他只能选择01/07/2022或更多。在API中找不到任何东西
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(2)
codesandbox.io
上面的答案允许在用户从第二个输入(结束日期)开始使用相同的日期,
增强的代码看起来像看起来像这是:
但是,这是ANTD范围选择器方法的限制,该方法与不显示哪个输入触发(开始或结束日期)有关。因此,例如,我选择了 5月22日至5月25日范围,并决定选择 5月22日至5月30日。在这种情况下,我必须仅在第二个输入中单击,因为第一个输入将封锁 5月22日选择,并且不允许进一步进行。
The answer above allows selecting same date when user starting doing so from the 2nd input ( end date )
The enhanced code can look like this:
But, here comes the limitation of this method of the antd range picker which is related to not showing which input was triggered ( start or end date ). So for example, I have selected May 22 - May 25 Range and decide to select May 22 - May 30. In this case, I must click only on 2nd input, because 1st input is gonna block May 22 from selection and won't allow to proceed further.