'How to format hidden input field in ftl/html
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...
Solution 1:[1]
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>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
