如何格式化ftl/html中隐藏输入字段

发布于 2025-01-29 11:44:07 字数 200 浏览 2 评论 0原文

我必须在HTML中使用两个字段键入文本,而这些字段则为这些字段。 现在,当我选择日期时,它们会自动填充文本字段,但在隐藏的输入字段中,这些值也将与时间存储。

像这样:

=“ 2022-04-13T00:00:00+02:00”

是否有一种格式化输入的方法:

value =“ 2022-04-13”

value

I have to two fields type text in html, and two datepicker for those fields.
Now, when I choose the dates, they automatically populate text fields but in hidden input field those values are stored with the time also.

Like this:

value="2022-04-13T00:00:00+02:00"

Is there a way to format that input to be like this:

value="2022-04-13"

Thanks in advance...

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

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

发布评论

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

评论(1

影子的影子 2025-02-05 11:44:07

您正在使用什么浏览器?
在此代码示例中,一切正常。

 <input id="date" type="date"  />
    <input id="hidden" type="hidden"  />
    <script>
      const date = document.querySelector("#date");
      const hidden = document.querySelector("#hidden");
      date.addEventListener("input", (e) => {
        hidden.value = date.value;
      });
    </script>

What browser are you using?
in this code example everything works as you expected.

 <input id="date" type="date"  />
    <input id="hidden" type="hidden"  />
    <script>
      const date = document.querySelector("#date");
      const hidden = document.querySelector("#hidden");
      date.addEventListener("input", (e) => {
        hidden.value = date.value;
      });
    </script>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文