如何使用Java脚本清除日历输入

发布于 2025-01-29 13:32:41 字数 468 浏览 1 评论 0原文

单击清除按钮

function resetTime() {
    document.getElementById("to_time").valueAsDate = null;
}

PrimeFaces日历标签后的JavaScript功能

<p:calendar id="to_time"
            value="#{anomaliesList.toDate}"
            readonlyInput="true"
            maxdate="#{currentDate}"
            size="16"
            pattern="dd/MM/yyyy HH:mm" />

JavaScript function after clicking on clear button

function resetTime() {
    document.getElementById("to_time").valueAsDate = null;
}

PrimeFaces calendar tag

<p:calendar id="to_time"
            value="#{anomaliesList.toDate}"
            readonlyInput="true"
            maxdate="#{currentDate}"
            size="16"
            pattern="dd/MM/yyyy HH:mm" />

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

苏璃陌 2025-02-05 13:32:41

首先,p:日历被弃用。使用p:datePicker而不是。

处理此问题的最简单方法是在p:datePicker上设置widgetvar。这允许您使用

要重置日期,请使用:

PF('yourWidgetName').setDate(null);

请注意,如果要使用getElementById,则可能需要合并表单clientId。

另请参见:

First of all, p:calendar is deprecated. Use p:datePicker instead.

The easiest way to deal with this is setting a widgetVar on your p:datePicker. This allows you to use the client side API.

To reset a date, use:

PF('yourWidgetName').setDate(null);

Note that if you want to use getElementById you probably need to incorporate the form clientId.

See also:

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文